- Console
- Change Kernel…
- Clear Console Cells
- Close and Shut Down…
- Insert Line Break
- Interrupt Kernel
- New Console
- Restart Kernel…
- Run Cell (forced)
- Run Cell (unforced)
- Show All Kernel Activity
- Extension Manager
- Enable Extension Manager (experimental)
- File Operations
- Autosave Documents
- Open from Path…Open from path
- Reload Notebook from DiskReload contents from disk
- Revert Notebook to CheckpointRevert contents to previous checkpoint
- Save NotebookSave and create checkpointCtrl+S
- Save Notebook As…Save with new pathCtrl+Shift+S
- Show Active File in File Browser
- Trust HTML File
- Help
- Jupyter Reference
- JupyterLab FAQ
- JupyterLab Reference
- Launch Classic Notebook
- Markdown Reference
- Reset Application State
- Image Viewer
- Flip image horizontallyH
- Flip image verticallyV
- Invert ColorsI
- Reset Image0
- Rotate Clockwise]
- Rotate Counterclockwise[
- Zoom In=
- Zoom Out-
- Kernel Operations
- Shut Down All Kernels…
- Launcher
- New Launcher
- Main Area
- Activate Next TabCtrl+Shift+]
- Activate Previous TabCtrl+Shift+[
- Activate Previously Used TabCtrl+Shift+'
- Close All Other Tabs
- Close All Tabs
- Close TabAlt+W
- Close Tabs to Right
- Find NextCtrl+G
- Find PreviousCtrl+Shift+G
- Find…Ctrl+F
- Log OutLog out of JupyterLab
- Presentation Mode
- Show Left SidebarCtrl+B
- Show Log Console
- Show Status Bar
- Shut DownShut down JupyterLab
- Single-Document ModeCtrl+Shift+D
- Notebook Cell Operations
- Change to Code Cell TypeY
- Change to Heading 11
- Change to Heading 22
- Change to Heading 33
- Change to Heading 44
- Change to Heading 55
- Change to Heading 66
- Change to Markdown Cell TypeM
- Change to Raw Cell TypeR
- Clear Outputs
- Collapse All Code
- Collapse All Outputs
- Collapse Selected Code
- Collapse Selected Outputs
- Copy CellsC
- Cut CellsX
- Delete CellsD, D
- Disable Scrolling for Outputs
- Enable Scrolling for Outputs
- Expand All Code
- Expand All Outputs
- Expand Selected Code
- Expand Selected Outputs
- Extend Selection AboveShift+K
- Extend Selection BelowShift+J
- Extend Selection to BottomShift+End
- Extend Selection to TopShift+Home
- Insert Cell AboveA
- Insert Cell BelowB
- Merge Selected CellsShift+M
- Move Cells Down
- Move Cells Up
- Paste Cells Above
- Paste Cells and Replace
- Paste Cells BelowV
- Redo Cell OperationShift+Z
- Run Selected CellsShift+Enter
- Run Selected Cells and Don't AdvanceCtrl+Enter
- Run Selected Cells and Insert BelowAlt+Enter
- Run Selected Text or Current Line in Console
- Select Cell AboveK
- Select Cell BelowJ
- Split CellCtrl+Shift+-
- Undo Cell OperationZ
- Notebook Operations
- Change Kernel…
- Clear All Outputs
- Close and Shut Down
- Deselect All Cells
- Enter Command ModeCtrl+M
- Enter Edit ModeEnter
- Export Notebook to Asciidoc
- Export Notebook to Executable Script
- Export Notebook to HTML
- Export Notebook to Html_ch
- Export Notebook to Html_embed
- Export Notebook to Html_toc
- Export Notebook to Html_with_lenvs
- Export Notebook to Html_with_toclenvs
- Export Notebook to LaTeX
- Export Notebook to Latex_with_lenvs
- Export Notebook to Markdown
- Export Notebook to PDF
- Export Notebook to ReStructured Text
- Export Notebook to Reveal.js Slides
- Export Notebook to SelectLanguage
- Export Notebook to Slides_with_lenvs
- Interrupt Kernel
- New Console for Notebook
- New NotebookCreate a new notebook
- Reconnect To Kernel
- Render All Markdown Cells
- Restart Kernel and Clear All Outputs…
- Restart Kernel and Run All Cells…
- Restart Kernel…
- Run All Above Selected Cell
- Run All Cells
- Run Selected Cell and All Below
- Select All CellsCtrl+A
- Toggle All Line NumbersShift+L
- Toggle Recording Cell Timing
- Trust Notebook
- Settings
- Advanced Settings EditorCtrl+,
- Show Contextual Help
- Show Contextual HelpLive updating code documentation from the active kernelCtrl+I
- Terminal
- Decrease Terminal Font Size
- Increase Terminal Font Size
- New TerminalStart a new terminal session
- Refresh TerminalRefresh the current terminal session
- Use Dark Terminal ThemeSet the terminal theme
- Use Inherit Terminal ThemeSet the terminal theme
- Use Light Terminal ThemeSet the terminal theme
- Text Editor
- Decrease Font Size
- Increase Font Size
- Indent with Tab
- New Markdown FileCreate a new markdown file
- New Text FileCreate a new text file
- Spaces: 1
- Spaces: 2
- Spaces: 4
- Spaces: 8
- Theme
- Decrease Code Font Size
- Decrease Content Font Size
- Decrease UI Font Size
- Increase Code Font Size
- Increase Content Font Size
- Increase UI Font Size
- Theme Scrollbars
- Use JupyterLab Dark Theme
- Use JupyterLab Light Theme
- Variable Inspector
- Open Variable Inspector
- downloads10 months ago
- MaxQuant2 hours ago
- metadata2 hours ago
- 200819_expt295_p3805.ipynb9 months ago
- e295 Comparing RBP Captures within Experimental Groups.ipynb9 minutes ago
- e295_redact_relabel.ipynb2 hours ago
- e295_RNP Enrichment Under Different pH - redacted - Copy.ipynb24 minutes ago
- e295_RNP Enrichment Under Different pH.ipynb9 months ago
Terminal Sessions
Kernel Sessions
- 200906.ipynb
- e295 Comparing RBP Captures within Experimental Groups.ipynb
- e295_RNP Enrichment Under Different pH.ipynb
- e295 Comparing RBP Captures within Experimental Groups.ipynb
- JupyterLab extension for running LaTeX
- Table of Contents extension for JupyterLab
- A JupyterLab extension.
- A JupyterLab extension for showing Notebook diffs.
- 200819 Expt.295: RNP Enrichment Under Different Conditionsplaceholder
- 1. Import Modules and Files
- 2. Metadata Creation
- 3. Re-Annotate the MaxQuant pGroups with stable Gene IDs
- 4. Review Contaminants by Sample
- 5. Assess Digestion Efficiency
- 6. Remove Contaminants
- 7. Drop Gene Duplicates and Filter Intensities by LFQ
- 8. Review Sample Clustering by Group
- 9. Analyse Normalisation Effects by Sample
- 10. Compare Intensity Distribution and Sequence Coverage
- 11. Compare Sum Peptide Counts
- 12. Compare Unique Gene Counts
- 13. Assess Replicate Correlation
- 14. Classify RBP
- 15. Compare RBP Identity Between Conditions
- 16. Compare RBP Isoelectric Points Between Conditions
- 17. Compare RBP Class I Identity with Previous Studies
- 18. Compare RBP Class I pI distribution to Previous Studies
- 19. Review Basic Gene Ontology
- 20. Retrieve GO Records
- 21. Analyse GO Memberships #1: RNA-binding
- 21. Analyse GO Memberships #1: Nucleic Acid Binding
xxxxxxxxxx## 16. Compare RBP Isoelectric Points Between Conditionsxxxxxxxxxx{}xxxxxxxxxx{ "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": false, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": {}, "toc_section_display": true, "toc_window_display": true }, "toc-autonumbering": false, "toc-showcode": false, "toc-showmarkdowntxt": false, "toc-showtags": true}- e295 Comparing RBP Captures within Experimental Groups.ipynb
x
# 200819 Expt.295: RNP Enrichment Under Different Conditions # 200819 Expt.295: RNP Enrichment Under Different Conditions _NB: This demonstration analysis was performed on unpublished development data. __Aims:__ A. To test the effects of conditions (cond) 1,2,3 on concentrating RBP-RNA complexes to the interphase of a customised Phenol-Chloroform Cocktail B. To compare these results with past studies 200819 Expt.295: RNP Enrichment Under Different Conditions
_NB: This demonstration analysis was performed on unpublished development data.
Aims:
A. To test the effects of conditions (cond) 1,2,3 on concentrating RBP-RNA complexes to the interphase of a customised Phenol-Chloroform Cocktail
B. To compare these results with past studies
xxxxxxxxxx1. Import Modules and Files
Custom Functions
jwrangle.importMixedFiles( )
I generally import everything I MIGHT use at the start and set up pathing using the OS-agnostic pathlib.
#### File utilitiesimport osimport pandas as pdfrom pathlib import Pathfrom imp import reload#### Data Wranglingimport copyimport numpy as np#### RBP Suite Modulesimport jwrangleimport jvisimport jinspectimport jtestimport jweb#### Sequence Toolsfrom Bio import SeqIO#### Graphical Packagesimport upsetplot as upsetimport seaborn as snsimport matplotlib.pyplot as pltimport altair as alt#### define working directoriescwd = Path(os.getcwd())base_path = Path(os.path.join(*cwd.parts[:cwd.parts.index('experiments')]))#### MaxQuant proteinGroups & evidence filesMQ_folder = jwrangle.importMixedFiles(cwd / 'MaxQuant')MQ_folder.keys()# pGroups = MQ_folder['proteinGroups.txt']# evidence = MQ_folder['evidence.txt']#### Inspect MQ setup# MQ_folder['parameters.txt'].head(9)C:\Users\smith.j\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\core\interactiveshell.py:3242: DtypeWarning: Columns (4,5,55,56,58,63) have mixed types.Specify dtype option on import or set low_memory=False. if (await self.run_code(code, result, async_=asy)):
dict_keys(['200706_mqpar.xml', 'e295r_evidence_metalabeled.txt', 'e295r_proteinGroups_metalabeled.txt', 'e295_evidence_metalabeled.txt', 'e295_proteinGroups_metalabeled.txt', 'evidence.txt', 'parameters.txt', 'proteinGroups.txt', 'summary.txt', 'tables.pdf'])
xxxxxxxxxx2. Metadata Creation
Custom Functions
jwrangle.MQ_writeMetadata( )
Metadata tabulates the test conditions for ALL experiments that shared the same MQ search and thuss all experiments that comprise the MQ outputs. Metadata can also be done in a spreadsheet program. Here, I have created my metadata programmatically instead (I simply find this easier).
The metadata table gives users the opportunity to rename samples and define the experimental parameters for the data. This task can be expecially complex for MaxQuant because a unified output is generated even if distinctly separate experiments are searched as a batch and with different parameters applied.
The function jwrangle.MQ_writeMetadata( ) will take a metadata table, rename all samples in the proteinGroups and evidence files, assign alternative filenames, and save new copies to be used in future analyses.
#### Done previouslyxxxxxxxxxx3. Re-Annotate the MaxQuant pGroups with stable Gene IDs
Functions
jweb.mapAnyID( )
jwrangle.importMixedFiles( )
MaxQuant does a good job of assigning a Gene name to each protein group. Presumably these gene names come from the FASTA. However:
- Sometimes it fails to find a gene name
- Sometimes it will assign an ID that is not a gene or include out-of-place characters
- It doesn't always seem to be consistent
- If the gene name originates from the FASTA then repeating the MQ search with an updated FASTA is the only way to update the gene IDs.
- Use of a mapping service will standardise the ID conversion practices between my datasets and those of others, including RNA-Seq.
To avoid these problems we will remap the Majority protein IDs to ENTREZ gene IDs. jweb.mapAnyID( ) will retrieve all possible genes for each protein group, and will also select a primary ID to singularly represent the group by a consistent method. This is a very flexible function, see help( ) for further explanation. From this point, the MQ 'Gene names' column will no longer be necessary. This function can also handle ID mapping to and from almost any convention.
Ensuring our proteins have a consistent gene naming strategy is essential for inter-experiment comparison and the later use of set methods. It also creates a standard that can be applied for accurately mapping RNA-Seq results and thus aid in future mapping of protein-RNA partners.
#### If not already loaded, read in the metadata-adjusted filesmetadata = pd.read_csv(cwd / 'metadata' / 'e295r_metadata.csv', index_col = 0)pGroups = pd.read_csv(cwd / 'MaxQuant' / 'e295r_proteinGroups_metalabeled.txt', delimiter = '\t')evidence = pd.read_csv(cwd / 'MaxQuant' / 'e295r_evidence_metalabeled.txt', delimiter = '\t')C:\Users\smith.j\AppData\Local\Continuum\anaconda3\lib\site-packages\IPython\core\interactiveshell.py:3051: DtypeWarning: Columns (4,5,55,56,58,63) have mixed types.Specify dtype option on import or set low_memory=False. interactivity=interactivity, compiler=compiler, result=result)
#### Dynamically remap gene names in our proteinGroups file and save a copy# pGroups_remap = jweb.mapAnyID_gPro(pGroups['Majority protein IDs'].tolist(), splitstr = [';', '-'], geneProductType = 'protein', # gConvertOrganism = 'hsapiens', gConvertTarget = 'ENTREZGENE', writetopath = [cwd, 'pGroups_remap'], writeTargetsAsList = 'NO')#### If not already loaded, read in the remapped proteinGroups filepGroups_remap = jwrangle.importMixedFiles(cwd / 'downloads' / 'pGroups_remap', dropSuffix = 'yes')pGroups_remap.keys()dict_keys(['id_map', 'query_map'])
#### jwrangle.importMixedFiles() returns a dictionary where keys = files. We want the 'id_map' table created by jweb.mapAnyID_gPro().#### We'll rename the Query column and drop duplicates so the table can be merged with our proteinGroups table.id_map = pGroups_remap['id_map'].rename(columns={'Query': 'Majority protein IDs'}).drop_duplicates()id_map.head(2)| Majority protein IDs | ENTREZGENE_gPro all | ENTREZGENE_gPro primary | ENTREZGENE_gPro name | UNIPROT_gPro status | |
|---|---|---|---|---|---|
| 0 | A0A024R4E5;Q00341;Q00341-2;H0Y394 | HDLBP;nan | HDLBP | high density lipoprotein binding protein [Sour... | SWISSPROT |
| 1 | A0A024R4M0;P46781;B5MCT8;C9JM19 | RPS9 | RPS9 | ribosomal protein S9 [Source:HGNC Symbol;Acc:H... | SWISSPROT |
#### Now use merge to add these new columns to our proteinGroups tablepGroups_map = pd.merge(pGroups, id_map, on='Majority protein IDs', how='left')#### Check the tables are merged by viewing column elements from each.pGroups_map[id_map.columns.tolist() + ['Peptide IDs']].head(2)| Majority protein IDs | ENTREZGENE_gPro all | ENTREZGENE_gPro primary | ENTREZGENE_gPro name | UNIPROT_gPro status | Peptide IDs | |
|---|---|---|---|---|---|---|
| 0 | A0A024R4E5;Q00341;Q00341-2;H0Y394 | HDLBP;nan | HDLBP | high density lipoprotein binding protein [Sour... | SWISSPROT | 25;321;749;763;961;1370;1398;1508;1663;1692;17... |
| 1 | A0A024R4M0;P46781;B5MCT8;C9JM19 | RPS9 | RPS9 | ribosomal protein S9 [Source:HGNC Symbol;Acc:H... | SWISSPROT | 2663;2664;4476;4677;4678;4818;5615;5914;6005;6... |
xxxxxxxxxx4. Review Contaminants by Sample
Functions
jinspect.MQ_getContaminants( )
MQ_getContaminants_sbplot( )
jwrangle.importMixedFiles( )
We can extract the conaminants from our proteinGroups file using jinspect.MQ_getContaminants( ). These extracted table will return log2(iBAQ values).
Contaminants can then be reviewed with MQ_getContaminants_sbplot( ).
#### Extract contaminantscontaminants = jinspect.MQ_getContaminants(pGroups_map, metadata)contaminants.head(2)D:\MEGA\Programming\Scripts_JS\RBP_SUITE\modules\jinspect.py:362: RuntimeWarning: divide by zero encountered in log2 pGroups_contaminants_log = (np.log2(pGroups_contaminants)).replace(-np.inf, 0)
| 01_Cond.1_nCL-A | 10_Cond.2_nCL-D | 11_Cond.2_nCL-E | 12_Cond.2_nCL-F | 13_Cond.3_nCL-A | 14_Cond.3_nCL-B | 15_Cond.3_nCL-C | 16_Cond.3_nCL-D | 17_Cond.3_nCL-E | 18_Cond.3_nCL-F | ... | 33_Cond.3_254-C | 34_Cond.3_254-D | 35_Cond.3_254-E | 36_Cond.3_254-F | 04_Cond.1_nCL-D | 05_Cond.1_nCL-E | 06_Cond.1_nCL-F | 07_Cond.2_nCL-A | 08_Cond.2_nCL-B | 09_Cond.2_nCL-C | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Protein ID: Gene | |||||||||||||||||||||
| ENSBTAP00000038253: nan | 0.000000 | 0.000000 | 0.00000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
| CON__P00761: nan | 25.804274 | 23.886416 | 27.46334 | 26.498277 | 24.591379 | 24.724216 | 26.948488 | 25.729178 | 23.444933 | 26.222748 | ... | 30.401516 | 30.038262 | 30.391205 | 30.435692 | 29.082636 | 30.063168 | 28.112969 | 25.805505 | 23.790345 | 24.178433 |
2 rows × 36 columns
#### Sort the metadata into a more intuitive ordermetadata_sort = metadata.sort_values(by = ['MQgroups','sample'])#### Visually inspect contaminants jvis.MQ_getContaminants_sbplot(contaminants, metadata_sort, width = 1, length = 2, layout = 'individual')<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
<Figure size 432x288 with 0 Axes>
xxxxxxxxxx5. Assess Digestion Efficiency
Functions
jinspect.MQ_getMissedCleavages( )
jvis.CommonPalettesAsHex
jvis.BarPlotByGroup_sbplot( )
Assessing missed cleavages is an essential metric for understanding the quality of the tryptic digestion. This data is recorded in the evidence file.
jinspect.MQ_getMissedCleavages( ) will return a long form data table that can easily be used for plotting.
The dictionary jvis.CommonPalettesAsHex contains a number of palettes that are common to both matplotlib and ggplot (from R). These are provided to ensure consistency is easy to achieve across both languages.
We'll plot the missed cleavages with the generic function jvis.BarPlotByGroup_sbplot( )
#### Extract the missed cleavage data into a long form table for plottingMissedCleavages = jinspect.MQ_getMissedCleavages(evidence, metadata, drop_contaminants = True)MissedCleavages.sort_values(by=['expt','sample'], inplace = True)MissedCleavages| sample | % Missed Cleavages | group | expt | |
|---|---|---|---|---|
| 4 | 01_Cond.1_nCL-A | 12 | Cond.1_nCL | Cond.1 |
| 10 | 02_Cond.1_nCL-B | 7 | Cond.1_nCL | Cond.1 |
| 17 | 03_Cond.1_nCL-C | 5 | Cond.1_nCL | Cond.1 |
| 11 | 04_Cond.1_nCL-D | 15 | Cond.1_nCL | Cond.1 |
| 21 | 05_Cond.1_nCL-E | 9 | Cond.1_nCL | Cond.1 |
| 6 | 06_Cond.1_nCL-F | 13 | Cond.1_nCL | Cond.1 |
| 29 | 19_Cond.1_254-A | 24 | Cond.1_254 | Cond.1 |
| 16 | 20_Cond.1_254-B | 21 | Cond.1_254 | Cond.1 |
| 20 | 21_Cond.1_254-C | 23 | Cond.1_254 | Cond.1 |
| 31 | 22_Cond.1_254-D | 22 | Cond.1_254 | Cond.1 |
| 3 | 23_Cond.1_254-E | 23 | Cond.1_254 | Cond.1 |
| 27 | 24_Cond.1_254-F | 23 | Cond.1_254 | Cond.1 |
| 30 | 07_Cond.2_nCL-A | 23 | Cond.2_nCL | Cond.2 |
| 32 | 08_Cond.2_nCL-B | 23 | Cond.2_nCL | Cond.2 |
| 35 | 09_Cond.2_nCL-C | 20 | Cond.2_nCL | Cond.2 |
| 25 | 10_Cond.2_nCL-D | 21 | Cond.2_nCL | Cond.2 |
| 15 | 11_Cond.2_nCL-E | 19 | Cond.2_nCL | Cond.2 |
| 5 | 12_Cond.2_nCL-F | 30 | Cond.2_nCL | Cond.2 |
| 13 | 25_Cond.2_254-A | 21 | Cond.2_254 | Cond.2 |
| 9 | 26_Cond.2_254-B | 23 | Cond.2_254 | Cond.2 |
| 22 | 27_Cond.2_254-C | 27 | Cond.2_254 | Cond.2 |
| 26 | 28_Cond.2_254-D | 26 | Cond.2_254 | Cond.2 |
| 14 | 29_Cond.2_254-E | 26 | Cond.2_254 | Cond.2 |
| 1 | 30_Cond.2_254-F | 26 | Cond.2_254 | Cond.2 |
| 2 | 13_Cond.3_nCL-A | 14 | Cond.3_nCL | Cond.3 |
| 28 | 14_Cond.3_nCL-B | 13 | Cond.3_nCL | Cond.3 |
| 24 | 15_Cond.3_nCL-C | 14 | Cond.3_nCL | Cond.3 |
| 19 | 16_Cond.3_nCL-D | 12 | Cond.3_nCL | Cond.3 |
| 23 | 17_Cond.3_nCL-E | 11 | Cond.3_nCL | Cond.3 |
| 18 | 18_Cond.3_nCL-F | 12 | Cond.3_nCL | Cond.3 |
| 7 | 31_Cond.3_254-A | 26 | Cond.3_254 | Cond.3 |
| 33 | 32_Cond.3_254-B | 26 | Cond.3_254 | Cond.3 |
| 12 | 33_Cond.3_254-C | 26 | Cond.3_254 | Cond.3 |
| 0 | 34_Cond.3_254-D | 25 | Cond.3_254 | Cond.3 |
| 34 | 35_Cond.3_254-E | 24 | Cond.3_254 | Cond.3 |
| 8 | 36_Cond.3_254-F | 26 | Cond.3_254 | Cond.3 |
### Select a colour palette cpal = jvis.CommonPalettesAsHexset2_paired = []for i in cpal['Set2_qual']: set2_paired.append(i) set2_paired.append(i)#### Plot the grouped data points sns.set_style('whitegrid')jvis.BarPlotByGroup_sbplot(MissedCleavages, x_col = 'group', y_col = '% Missed Cleavages', title = '% Missed Cleavages', pal = set2_paired)<Figure size 432x288 with 0 Axes>
xxxxxxxxxx6. Remove Contaminants
Functions
jwrangle.MQ_getThreePassFilter( )
SeqIO.parse( )
After QC we no longer want the contaminants in our data. jwrangle.MQ_getThreePassFilter( ) will remove reverse peptides, contaminants, and only identified by site from MQ tables.
The filter will also accept customised exclusion lists in case users have added odd protein species to the search FASTA tables. In this particular experiment we added to the human FASTA, RNAse proteins and the large T antigen. The former as 1) a check that dynamic range is not being overwhelmed and 2) as an quantitative spike-in control to compare tryptic efficiency and the sample recovery across samples following C18 cleanup.
#### Map the location of the custom FASTA elementsos.listdir(base_path / 'my_resources' / 'FASTA') #### Create a list of the non-human proteins that were added to the custom FASTA genome search. new_cont = []with open(base_path / 'my_resources' / 'FASTA' / "custom_proteome_elements.fasta", "r") as handle: for record in SeqIO.parse(handle, "fasta"): new_cont.append(record.id.split('|')[1])#### Remove all unwanted contaminants and IDs from the proteinGroups table pGroup_clean = jwrangle.MQ_getThreePassFilter(pGroups_map, custom_exclusion = new_cont)#### Inspect the cleaned dataframepGroup_clean[['ENTREZGENE_gPro primary'] + [i for i in pGroup_clean.columns if 'iBAQ' in i]].head(2)| ENTREZGENE_gPro primary | iBAQ | iBAQ 01_Cond.1_nCL-A | iBAQ 10_Cond.2_nCL-D | iBAQ 11_Cond.2_nCL-E | iBAQ 12_Cond.2_nCL-F | iBAQ 13_Cond.3_nCL-A | iBAQ 14_Cond.3_nCL-B | iBAQ 15_Cond.3_nCL-C | iBAQ 16_Cond.3_nCL-D | ... | iBAQ 33_Cond.3_254-C | iBAQ 34_Cond.3_254-D | iBAQ 35_Cond.3_254-E | iBAQ 36_Cond.3_254-F | iBAQ 04_Cond.1_nCL-D | iBAQ 05_Cond.1_nCL-E | iBAQ 06_Cond.1_nCL-F | iBAQ 07_Cond.2_nCL-A | iBAQ 08_Cond.2_nCL-B | iBAQ 09_Cond.2_nCL-C | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | HDLBP | 1.965600e+08 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 16325000.0 | 9819400.0 | 16333000.0 | 21658000.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
| 1 | RPS9 | 2.840400e+09 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | ... | 244410000.0 | 159950000.0 | 251630000.0 | 333440000.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 |
2 rows × 38 columns
xxxxxxxxxx7. Drop Gene Duplicates and Filter Intensities by LFQ
Functions
jinspect.MQ_dropDuplicateIDs( )
The next step focuses on improving confidence in the quality of our data. This is done by applying jinspect.MQ_dropDuplicateIDs( ) which has the below effects:
- Because one gene can have many proteins, sometimes Maxquant will create multiple proteinGroups for a single gene. As most of our analysis focuses on genes we'll trim the lowest quality proteinGroups duplicates from the table.
- Standard LFQ defaults require a minimum of 2 peptide species, at least one of which must be unique, for quantitation to be applied. Intensity and iBAQ values, however, do not have such a minimum limit. I consider a 2 peptide minimum to be a wise filter but still have use for the Intensity and iBAQ values. Thus where the LFQ filter is applied all measurements that do not meet the minimum limit will be discarded. In short, if there isn't a companion LFQ value, there won't be an Intensity or iBAQ value either after filtering.
- It has been documented that Match Between Runs suffers a high frequency of false peptide transfers (Lim, Paulo, Gygi 2019; doi: 10.1021/acs.jproteome.9b00492). At the protein level, however, this false transfer rate is greatly mitigated by the minimum peptide rule applied by the LFQ algorithm. This is another good reason for our filtering step.
#### Drop duplicates and apply LFQ filterfilter_dict = jinspect.MQ_dropDuplicateIDs(pGroup_clean, metadata, prefix = 'Peptides', ID = 'ENTREZGENE_gPro primary', pool = 'measure', drop_ID = 'None', keep_PoolCalcs = False, applyLFQ_filter = ['Intensity', 'iBAQ'])#### Inspect filter dictionaryfilter_dict.keys()WARNING: jinspect.MQ_getMeasuredMeansByGroup() has not been checked
dict_keys(['df_keep', 'df_droprows'])
#### The df_keep value contains our targets, df_droprows conatins the discarded duplicates. Assign the df_keep value to a new variable and inspect.pGroup_filtered = filter_dict['df_keep']pGroup_filtered.head(2)| Protein IDs | Majority protein IDs | Peptide counts (all) | Peptide counts (razor+unique) | Peptide counts (unique) | Protein names | Gene names | Fasta headers | Number of proteins | Peptides | ... | iBAQ 27_Cond.2_254-C | iBAQ 28_Cond.2_254-D | iBAQ 29_Cond.2_254-E | iBAQ 30_Cond.2_254-F | iBAQ 31_Cond.3_254-A | iBAQ 32_Cond.3_254-B | iBAQ 33_Cond.3_254-C | iBAQ 34_Cond.3_254-D | iBAQ 35_Cond.3_254-E | iBAQ 36_Cond.3_254-F | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | A0A024R4E5;Q00341;Q00341-2;H0Y394;H7C0A4;C9JIZ... | A0A024R4E5;Q00341;Q00341-2;H0Y394 | 52;51;47;36;17;15;14;12;11;11;10;10;8;6;6;5;5;... | 52;51;47;36;17;15;14;12;11;11;10;10;8;6;6;5;5;... | 52;51;47;36;17;15;14;12;11;11;10;10;8;6;6;5;5;... | Vigilin | HDLBP | ;;; | 23 | 52 | ... | 13159000.0 | 9700500.0 | 13087000.0 | 16089000.0 | 14684000.0 | 18556000.0 | 16325000.0 | 9819400.0 | 16333000.0 | 21658000.0 |
| 1 | A0A024R4M0;P46781;B5MCT8;C9JM19;F2Z3C0;A8MXK4 | A0A024R4M0;P46781;B5MCT8;C9JM19 | 15;15;12;12;3;3 | 15;15;12;12;3;3 | 15;15;12;12;3;3 | 40S ribosomal protein S9 | RPS9 | ;;; | 6 | 15 | ... | 203450000.0 | 146150000.0 | 218280000.0 | 260780000.0 | 157770000.0 | 186250000.0 | 244410000.0 | 159950000.0 | 251630000.0 | 333440000.0 |
2 rows × 370 columns
xxxxxxxxxx8. Review Sample Clustering by Group
Functions
jtest.getDistanceMatrix( )
jvis.MQ_showDendrogramQC_mplplot( )
A distance matrix function jtest.getDistanceMatrix( ) is provided for users who wish to apply different algorithms or create different visualisations.
I like the 'ward' method for distance calculations and using a dengrogram to confirm that clustering matches expectations and so use a prerolled function jvis.MQ_showDendrogramQC_mplplot( )
#### Confirm that clustering matches expectationsjvis.MQ_showDendrogramQC_mplplot(pGroup_filtered, 'LFQ intensity', metadata, 'QC clustering: ', grid = 'YES', fsize = (8, 8))xxxxxxxxxx9. Analyse Normalisation Effects by Sample
Functions
jwrangle.Log2_ByPrefix( )
jwrangle.MQ_poolMulti( )
jvis.ViolinCompare_sbplot( )
Here we review normalisation effects on each sample within the condition groups; these are most easily interpreted after log2 transformation. We will transform all measures of interest with jwrangle.Log2_ByPrefix( ) and then pool all the values of interest, by condition, with jwrangle.MQ_poolMulti( ). The function jvis.ViolinCompare_sbplot( ) will let use compare Intensity distribution on a per sample basis.
Normalisation is applied to LFQ values by MaxQuant and is a feature of its handling of label-free data. I've not seen a detailed explanation of how it works though so it is a leap of faith that Cox and Mann have selected an appropriate method.
Normalisation must be applied separately to nCL and cCL groups. This is unusual though necessary to avoid outrageous results caused by having groups with extreme differences. See expt.313 for evidence.
#### Log2 transform available intensity values.pGroup_log2 = jwrangle.Log2_ByPrefix(pGroup_filtered, 'LFQ intensity')pGroup_log2 = jwrangle.Log2_ByPrefix(pGroup_log2, 'iBAQ')pGroup_log2 = jwrangle.Log2_ByPrefix(pGroup_log2, 'Intensity')pGroup_log2.replace(0,np.nan, inplace=True)C:\Users\smith.j\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\series.py:679: RuntimeWarning: divide by zero encountered in log2 result = getattr(ufunc, method)(*inputs, **kwargs)
#### Create a long form dataset for each desired groupingpool_SampleIntensity = jwrangle.MQ_poolMulti(pGroup_log2, metadata, melt_list = ['Intensity', 'LFQ intensity'], group = 'condition')pool_SampleIntensity.keys()dict_keys(['Cond.1_nCL', 'Cond.2_nCL', 'Cond.3_nCL', 'Cond.1_254', 'Cond.2_254', 'Cond.3_254'])
#### Inspect the Intensity shifts generated by the LFQ normalisation algorithm. In MaxQuant Raw Intensity and iBAQ values are #### not subjected to the LFQ normalisation calculations so this is a good way to spot any gross violationssns.set_style('whitegrid')jvis.ViolinCompare_sbplot(pool_SampleIntensity['Cond.1_nCL'], title = 'Cond.1 nCL: Normalisation Effects', ylabel = 'Log2(Intensity)', palette = ['#ff6666', '#99ccff'])#### Inspect the Intensity shifts generated by the LFQ normalisation algorithm. In MaxQuant Raw Intensity and iBAQ values are #### not subjected to the LFQ normalisation calculations so this is a good way to spot any gross violationssns.set_style('whitegrid')jvis.ViolinCompare_sbplot(pool_SampleIntensity['Cond.2_nCL'], title = 'Cond.2 nCL: Normalisation Effects', ylabel = 'Log2(Intensity)', palette = ['#ff6666', '#99ccff'])#### Inspect the Intensity shifts generated by the LFQ normalisation algorithm. In MaxQuant Raw Intensity and iBAQ values are #### not subjected to the LFQ normalisation calculations so this is a good way to spot any gross violationssns.set_style('whitegrid')jvis.ViolinCompare_sbplot(pool_SampleIntensity['Cond.3_nCL'], title = 'Cond.3 nCL: Normalisation Effects', ylabel = 'Log2(Intensity)', palette = ['#ff6666', '#99ccff'])jvis.ViolinCompare_sbplot(pool_SampleIntensity['Cond.1_254'], title = 'Cond.1 254: Normalisation Effects', ylabel = 'Log2(Intensity)', palette = cpal['Set3_qual'])jvis.ViolinCompare_sbplot(pool_SampleIntensity['Cond.2_254'], title = 'Cond.2 nCL: Normalisation Effects', ylabel = 'Log2(Intensity)', palette = cpal['Set3_qual'])jvis.ViolinCompare_sbplot(pool_SampleIntensity['Cond.3_254'], title = 'Cond.3 nCL: Normalisation Effects', ylabel = 'Log2(Intensity)', palette = cpal['Set3_qual'])xxxxxxxxxx10. Compare Intensity Distribution and Sequence Coverage
Functions
jwrangle.MQ_poolDataByCondition( )
jvis.BoxPlotByColumn_sbplot( )
Next we will compare intensity and sequence coverage between groups. Log2 transformation has already been performed so we need only use jwrangle.MQ_poolDataByCondition( ) to create the appropriate long form dataset for plotting with jvis.BoxPlotByColumn_sbplot( ).
#### Pool data into a single long form datasetpooled_dfDropGroupOne = jwrangle.MQ_poolDataByCondition(pGroup_log2, metadata_sort, prefix_list = ['Intensity', 'Sequence coverage'])#### Compare Intensity distribution using a box and whisker plotsns.set_style('whitegrid')jvis.BoxPlotByColumn_sbplot(pooled_dfDropGroupOne, 'Intensity: ', 'Intensity')#### Compare Sequence coverage using a box and whisker plotsns.set_style('whitegrid')jvis.BoxPlotByColumn_sbplot(pooled_dfDropGroupOne, 'Sequence coverage: ', 'Sequence coverage %')xxxxxxxxxx11. Compare Sum Peptide Counts
Functions
jinspect.MQ_getSumBySample( )
jvis.BarPlotByGroup_sbplot( )
To sum the total peptides observed across all proteins use jinspect.MQ_getSumBySample( ). These sums will be returned as a modified metadata table.
Plotting these by group is easily done with jvis.BarPlotByGroup_sbplot( ). The plotting order is determined by the metadata ordering.
In this case we are inspecting the number of peptides detected after having removed contaminants- thus if some spike-in proteins were removed, i.e. in this case RNAse treatments, they will not contribute to the peptide count. To look at the replicability of these spike-ins, we would reach back to the 'df_droprows' table generated by jinspect.MQ_dropDuplicateIDs( ) in section 7.
#### Extract the total peptides observed per samplemetaStats = jinspect.MQ_getSumBySample(pGroup_log2, metadata_sort, freqList = ['Peptides'], measure = False)metaStats| experiment | condition | replicate | sample | measure | MQgroups | Peptides | |
|---|---|---|---|---|---|---|---|
| 0 | 05v2_1_pH4OdT_NC-A | Cond.1_nCL | A | 01_Cond.1_nCL-A | Intensity | Cond.1 | 153.0 |
| 1 | 05v2_2_pH4OdT_NC-B | Cond.1_nCL | B | 02_Cond.1_nCL-B | Intensity | Cond.1 | 115.0 |
| 2 | 05v2_3_pH4OdT_NC-C | Cond.1_nCL | C | 03_Cond.1_nCL-C | Intensity | Cond.1 | 76.0 |
| 3 | 05v2_4_pH4OdT_NC-D | Cond.1_nCL | D | 04_Cond.1_nCL-D | Intensity | Cond.1 | 55.0 |
| 4 | 05v2_5_pH4OdT_NC-E | Cond.1_nCL | E | 05_Cond.1_nCL-E | Intensity | Cond.1 | 205.0 |
| 5 | 05v2_6_pH4OdT_NC-F | Cond.1_nCL | F | 06_Cond.1_nCL-F | Intensity | Cond.1 | 60.0 |
| 6 | 05v2_19_pH4OdT_PC-A | Cond.1_254 | A | 19_Cond.1_254-A | Intensity | Cond.1 | 5840.0 |
| 7 | 05v2_20_pH4OdT_PC-B | Cond.1_254 | B | 20_Cond.1_254-B | Intensity | Cond.1 | 4324.0 |
| 8 | 05v2_21_pH4OdT_PC-C | Cond.1_254 | C | 21_Cond.1_254-C | Intensity | Cond.1 | 5080.0 |
| 9 | 05v2_22_pH4OdT_PC-D | Cond.1_254 | D | 22_Cond.1_254-D | Intensity | Cond.1 | 6158.0 |
| 10 | 05v2_23_pH4OdT_PC-E | Cond.1_254 | E | 23_Cond.1_254-E | Intensity | Cond.1 | 6428.0 |
| 11 | 05v2_24_pH4OdT_PC-F | Cond.1_254 | F | 24_Cond.1_254-F | Intensity | Cond.1 | 6274.0 |
| 12 | 05v2_7_pH5OdT_NC-A | Cond.2_nCL | A | 07_Cond.2_nCL-A | Intensity | Cond.2 | 55.0 |
| 13 | 05v2_8_pH5OdT_NC-B | Cond.2_nCL | B | 08_Cond.2_nCL-B | Intensity | Cond.2 | 67.0 |
| 14 | 05v2_9_pH5OdT_NC-C | Cond.2_nCL | C | 09_Cond.2_nCL-C | Intensity | Cond.2 | 41.0 |
| 15 | 05v2_10_pH5OdT_NC-D | Cond.2_nCL | D | 10_Cond.2_nCL-D | Intensity | Cond.2 | 55.0 |
| 16 | 05v2_11_pH5OdT_NC-E | Cond.2_nCL | E | 11_Cond.2_nCL-E | Intensity | Cond.2 | 61.0 |
| 17 | 05v2_12_pH5OdT_NC-F | Cond.2_nCL | F | 12_Cond.2_nCL-F | Intensity | Cond.2 | 40.0 |
| 18 | 05v2_25_pH5OdT_PC-A | Cond.2_254 | A | 25_Cond.2_254-A | Intensity | Cond.2 | 4522.0 |
| 19 | 05v2_26_pH5OdT_PC-B | Cond.2_254 | B | 26_Cond.2_254-B | Intensity | Cond.2 | 7112.0 |
| 20 | 05v2_27_pH5OdT_PC-C | Cond.2_254 | C | 27_Cond.2_254-C | Intensity | Cond.2 | 8984.0 |
| 21 | 05v2_28_pH5OdT_PC-D | Cond.2_254 | D | 28_Cond.2_254-D | Intensity | Cond.2 | 8578.0 |
| 22 | 05v2_29_pH5OdT_PC-E | Cond.2_254 | E | 29_Cond.2_254-E | Intensity | Cond.2 | 8842.0 |
| 23 | 05v2_30_pH5OdT_PC-F | Cond.2_254 | F | 30_Cond.2_254-F | Intensity | Cond.2 | 9028.0 |
| 24 | 05v2_13_pH8OdT_NC-A | Cond.3_nCL | A | 13_Cond.3_nCL-A | Intensity | Cond.3 | 88.0 |
| 25 | 05v2_14_pH8OdT_NC-B | Cond.3_nCL | B | 14_Cond.3_nCL-B | Intensity | Cond.3 | 80.0 |
| 26 | 05v2_15_pH8OdT_NC-C | Cond.3_nCL | C | 15_Cond.3_nCL-C | Intensity | Cond.3 | 77.0 |
| 27 | 05v2_16_pH8OdT_NC-D | Cond.3_nCL | D | 16_Cond.3_nCL-D | Intensity | Cond.3 | 93.0 |
| 28 | 05v2_17_pH8OdT_NC-E | Cond.3_nCL | E | 17_Cond.3_nCL-E | Intensity | Cond.3 | 56.0 |
| 29 | 05v2_18_pH8OdT_NC-F | Cond.3_nCL | F | 18_Cond.3_nCL-F | Intensity | Cond.3 | 97.0 |
| 30 | 05v2_31_pH8OdT_PC-A | Cond.3_254 | A | 31_Cond.3_254-A | Intensity | Cond.3 | 9700.0 |
| 31 | 05v2_32_pH8OdT_PC-B | Cond.3_254 | B | 32_Cond.3_254-B | Intensity | Cond.3 | 9805.0 |
| 32 | 05v2_33_pH8OdT_PC-C | Cond.3_254 | C | 33_Cond.3_254-C | Intensity | Cond.3 | 10262.0 |
| 33 | 05v2_34_pH8OdT_PC-D | Cond.3_254 | D | 34_Cond.3_254-D | Intensity | Cond.3 | 9858.0 |
| 34 | 05v2_35_pH8OdT_PC-E | Cond.3_254 | E | 35_Cond.3_254-E | Intensity | Cond.3 | 9986.0 |
| 35 | 05v2_36_pH8OdT_PC-F | Cond.3_254 | F | 36_Cond.3_254-F | Intensity | Cond.3 | 10492.0 |
#### Plot the sum peptidessns.set_style('whitegrid')jvis.BarPlotByGroup_sbplot(metaStats, x_col = 'condition', y_col = 'Peptides', title = 'Sum Peptides vs Condition', pal = set2_paired, errorbars = 'SEM')<Figure size 432x288 with 0 Axes>
xxxxxxxxxx12. Compare Unique Gene Counts
Functions
jinspect.MQ_getFrequencyBySample( )
One gene can encode for many proteins that often share regions of similarity. As for illumina-based RNA-Seq, however, shotgun proteomics can rarely assign a peptide species to a singular protein. In MaxQuant these are called proteinGroups. Because we have do not require protein-specific results, and gene identity is more stable, our gene count describes the groups to which our detected proteins have been be assigned. Thus gene here is being detected by protein product, just as it would be detected by RNA product in RNA Seq; none of these 3 are synonymous. To be clear, this is a count and not a measure.
Gene frequency is defined by the summed observations per protein regardless of intensity value and this data is extracted to our modified metadata with jinspect.MQ_getFrequencyBySample( ) .
A typical MQ search will yield identical protein counts (though different values) for Intensity and iBAQ*. LFQ frequencies will vary depending on the search settings:
- In this case the MQ search has set LFQ values to be calculated on a min 2 peptide ratio (this is the default)**
Notes
* Why protein counts should be identical I don't know. The original iBAQ paper stipulates rules for the inclusion of a protein in the iBAQ calculation but MaxQuant doesn't seem to apply them.
** Previously I tested LFQ min ratio at 1 peptide. At 1 minimum peptide there was unexpected QC clustering. Possible explanations for this are explained in section 7 and are cleaned up by jinspect.MQ_dropDuplicateIDs( ) function. We can expect this function to greatly reduce qualifying IDs (~20% fewer), especially in the QE samples, but I think the trade-off is worth it because we gain 1) a more robust ID check and 2) the same search can be used for LFQ based checks of dynamic changes, i.e. comparing more than one group of cCL captures for biological changes.
#### Count the number of unique metaStats = jinspect.MQ_getFrequencyBySample(pGroup_log2, metaStats, freqList = ['Intensity', 'iBAQ', 'LFQ intensity'], measure = False)metaStats.iloc[:, 1:]| condition | replicate | sample | measure | MQgroups | Peptides | Intensity | iBAQ | LFQ intensity | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | Cond.1_nCL | A | 01_Cond.1_nCL-A | Intensity | Cond.1 | 153.0 | 31 | 31 | 31 |
| 1 | Cond.1_nCL | B | 02_Cond.1_nCL-B | Intensity | Cond.1 | 115.0 | 24 | 24 | 24 |
| 2 | Cond.1_nCL | C | 03_Cond.1_nCL-C | Intensity | Cond.1 | 76.0 | 16 | 16 | 16 |
| 3 | Cond.1_nCL | D | 04_Cond.1_nCL-D | Intensity | Cond.1 | 55.0 | 13 | 13 | 13 |
| 4 | Cond.1_nCL | E | 05_Cond.1_nCL-E | Intensity | Cond.1 | 205.0 | 66 | 66 | 66 |
| 5 | Cond.1_nCL | F | 06_Cond.1_nCL-F | Intensity | Cond.1 | 60.0 | 21 | 21 | 21 |
| 6 | Cond.1_254 | A | 19_Cond.1_254-A | Intensity | Cond.1 | 5840.0 | 633 | 633 | 633 |
| 7 | Cond.1_254 | B | 20_Cond.1_254-B | Intensity | Cond.1 | 4324.0 | 530 | 530 | 530 |
| 8 | Cond.1_254 | C | 21_Cond.1_254-C | Intensity | Cond.1 | 5080.0 | 571 | 571 | 571 |
| 9 | Cond.1_254 | D | 22_Cond.1_254-D | Intensity | Cond.1 | 6158.0 | 652 | 652 | 652 |
| 10 | Cond.1_254 | E | 23_Cond.1_254-E | Intensity | Cond.1 | 6428.0 | 691 | 691 | 691 |
| 11 | Cond.1_254 | F | 24_Cond.1_254-F | Intensity | Cond.1 | 6274.0 | 795 | 795 | 795 |
| 12 | Cond.2_nCL | A | 07_Cond.2_nCL-A | Intensity | Cond.2 | 55.0 | 13 | 13 | 13 |
| 13 | Cond.2_nCL | B | 08_Cond.2_nCL-B | Intensity | Cond.2 | 67.0 | 17 | 17 | 17 |
| 14 | Cond.2_nCL | C | 09_Cond.2_nCL-C | Intensity | Cond.2 | 41.0 | 22 | 22 | 22 |
| 15 | Cond.2_nCL | D | 10_Cond.2_nCL-D | Intensity | Cond.2 | 55.0 | 12 | 12 | 12 |
| 16 | Cond.2_nCL | E | 11_Cond.2_nCL-E | Intensity | Cond.2 | 61.0 | 11 | 11 | 11 |
| 17 | Cond.2_nCL | F | 12_Cond.2_nCL-F | Intensity | Cond.2 | 40.0 | 9 | 9 | 9 |
| 18 | Cond.2_254 | A | 25_Cond.2_254-A | Intensity | Cond.2 | 4522.0 | 514 | 514 | 514 |
| 19 | Cond.2_254 | B | 26_Cond.2_254-B | Intensity | Cond.2 | 7112.0 | 760 | 760 | 760 |
| 20 | Cond.2_254 | C | 27_Cond.2_254-C | Intensity | Cond.2 | 8984.0 | 854 | 854 | 854 |
| 21 | Cond.2_254 | D | 28_Cond.2_254-D | Intensity | Cond.2 | 8578.0 | 838 | 838 | 838 |
| 22 | Cond.2_254 | E | 29_Cond.2_254-E | Intensity | Cond.2 | 8842.0 | 859 | 859 | 859 |
| 23 | Cond.2_254 | F | 30_Cond.2_254-F | Intensity | Cond.2 | 9028.0 | 986 | 986 | 986 |
| 24 | Cond.3_nCL | A | 13_Cond.3_nCL-A | Intensity | Cond.3 | 88.0 | 14 | 14 | 14 |
| 25 | Cond.3_nCL | B | 14_Cond.3_nCL-B | Intensity | Cond.3 | 80.0 | 17 | 17 | 17 |
| 26 | Cond.3_nCL | C | 15_Cond.3_nCL-C | Intensity | Cond.3 | 77.0 | 15 | 15 | 15 |
| 27 | Cond.3_nCL | D | 16_Cond.3_nCL-D | Intensity | Cond.3 | 93.0 | 18 | 18 | 18 |
| 28 | Cond.3_nCL | E | 17_Cond.3_nCL-E | Intensity | Cond.3 | 56.0 | 13 | 13 | 13 |
| 29 | Cond.3_nCL | F | 18_Cond.3_nCL-F | Intensity | Cond.3 | 97.0 | 36 | 36 | 36 |
| 30 | Cond.3_254 | A | 31_Cond.3_254-A | Intensity | Cond.3 | 9700.0 | 942 | 942 | 942 |
| 31 | Cond.3_254 | B | 32_Cond.3_254-B | Intensity | Cond.3 | 9805.0 | 955 | 955 | 955 |
| 32 | Cond.3_254 | C | 33_Cond.3_254-C | Intensity | Cond.3 | 10262.0 | 961 | 961 | 961 |
| 33 | Cond.3_254 | D | 34_Cond.3_254-D | Intensity | Cond.3 | 9858.0 | 958 | 958 | 958 |
| 34 | Cond.3_254 | E | 35_Cond.3_254-E | Intensity | Cond.3 | 9986.0 | 972 | 972 | 972 |
| 35 | Cond.3_254 | F | 36_Cond.3_254-F | Intensity | Cond.3 | 10492.0 | 1104 | 1104 | 1104 |
#### Plot the countssns.set_style('whitegrid')jvis.BarPlotByGroup_sbplot(metaStats, x_col = 'condition', y_col = 'Intensity', title = '# Genes Detected By Group', pal = set2_paired, ylabel = 'Unique Genes', errorbars = 'SEM')<Figure size 432x288 with 0 Axes>
xxxxxxxxxx13. Assess Replicate Correlation
Functions
jwrangle.MQ_getSliceByPrefix( )
jvis.showPearsonRegression_altair( )
The function jwrangle.MQ_getSliceByPrefix( ) provides a convenient means of extracting values of a specific group.
We can then use jvis.showPearsonRegression_altair( ) to perform pairwise comparisons between each member of those groups. This function is specifically applied to genes with shared intensities- genes exclusive to one sample or the other, represented by vertical or horizontal datapoints, are plotted but excluded from the pearson calculation.
#### Extract the intensity values as a dictionary where keys = groupsIntensity_Dict = jwrangle.MQ_getSliceByPrefix(pGroup_log2, metadata, 'Intensity', group = 'condition', add_col = None)Intensity_Dict.keys()dict_keys(['Cond.1_nCL', 'Cond.2_nCL', 'Cond.3_nCL', 'Cond.1_254', 'Cond.2_254', 'Cond.3_254'])
#### Check replicate consistency across all within group pairsjvis.showPearsonRegression_altair(Intensity_Dict['Cond.1_nCL'], mark_color = set2_paired[2])jvis.showPearsonRegression_altair(Intensity_Dict['Cond.1_254'], mark_color = set2_paired[2])jvis.showPearsonRegression_altair(Intensity_Dict['Cond.2_nCL'], mark_color = set2_paired[4])jvis.showPearsonRegression_altair(Intensity_Dict['Cond.2_254'], mark_color = set2_paired[4])jvis.showPearsonRegression_altair(Intensity_Dict['Cond.3_nCL'], mark_color = set2_paired[6])jvis.showPearsonRegression_altair(Intensity_Dict['Cond.3_254'], mark_color = set2_paired[6])xxxxxxxxxx14. Classify RBP
Functions
jinspect.MQ_getFrequencyByGroup()
jtest.MQ_applyClassifyRBP()
Before classifying our RBP we need to first tally the frequency with which each protein appears in each condition using jinspect.MQ_getFrequencyByGroup( )
Once done, we use jtest.MQ_applyClassifyRBP( ) to generate a dictionary from which each class can be reviewed or plotted.
#### Use the metadata and proteinGroups tables to count how many times a gene is identified in its group (/6). #### Here I demonstrate how we can count for all instances of Intensity, iBAQ and LFQ IntensitypGroup_Freq = jinspect.MQ_getFrequencyByGroup(pGroup_log2, metadata, 'iBAQ', group = 'condition')pGroup_Freq = jinspect.MQ_getFrequencyByGroup(pGroup_Freq, metadata, 'LFQ intensity', group = 'condition')pGroup_Freq = jinspect.MQ_getFrequencyByGroup(pGroup_Freq, metadata, 'Intensity', group = 'condition')pGroup_Freq[['ENTREZGENE_gPro primary'] + [i for i in pGroup_Freq.columns if 'Freq' in i]].head(2)| ENTREZGENE_gPro primary | iBAQ Freq: Cond.1_nCL | iBAQ Freq: Cond.2_nCL | iBAQ Freq: Cond.3_nCL | iBAQ Freq: Cond.1_254 | iBAQ Freq: Cond.2_254 | iBAQ Freq: Cond.3_254 | LFQ intensity Freq: Cond.1_nCL | LFQ intensity Freq: Cond.2_nCL | LFQ intensity Freq: Cond.3_nCL | LFQ intensity Freq: Cond.1_254 | LFQ intensity Freq: Cond.2_254 | LFQ intensity Freq: Cond.3_254 | Intensity Freq: Cond.1_nCL | Intensity Freq: Cond.2_nCL | Intensity Freq: Cond.3_nCL | Intensity Freq: Cond.1_254 | Intensity Freq: Cond.2_254 | Intensity Freq: Cond.3_254 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | HDLBP | 0 | 0 | 0 | 6 | 6 | 6 | 0 | 0 | 0 | 6 | 6 | 6 | 0 | 0 | 0 | 6 | 6 | 6 |
| 1 | RPS9 | 1 | 0 | 1 | 6 | 6 | 6 | 1 | 0 | 1 | 6 | 6 | 6 | 1 | 0 | 1 | 6 | 6 | 6 |
#### Now we can classify RBP; the console will report if all proteins/genes have been properly classified or not.RBP_Dict_Cond1 = jtest.MQ_applyClassifyRBP(pGroup_Freq, 'LFQ intensity', metadata, 'Cond.1', 'Cond.1_nCL', 'Cond.1_254', 3, add_cols = ['ENTREZGENE_gPro all', 'ENTREZGENE_gPro primary', 'ENTREZGENE_gPro name'])RBP_Dict_Cond2 = jtest.MQ_applyClassifyRBP(pGroup_Freq, 'LFQ intensity', metadata, 'Cond.2', 'Cond.2_nCL', 'Cond.2_254', 3, add_cols = ['ENTREZGENE_gPro all', 'ENTREZGENE_gPro primary', 'ENTREZGENE_gPro name'])RBP_Dict_Cond3 = jtest.MQ_applyClassifyRBP(pGroup_Freq, 'LFQ intensity', metadata, 'Cond.3', 'Cond.3_nCL', 'Cond.3_254', 3, add_cols = ['ENTREZGENE_gPro all', 'ENTREZGENE_gPro primary', 'ENTREZGENE_gPro name'])All proteins classified = True All proteins classified = True All proteins classified = True
#### The results of this classifcation can be found in a dictionary of dataframes for each output#### See help() for an explanation of each datasetRBP_Dict_Cond3.keys()dict_keys(['Input_df_annStatus', 'Summary_df_annStatus', 'I', 'IIa', 'IIb', 'IIc', 'NC', 'ND'])
#### We want the most general overview which of our classes per treatment and so concatenate the results from each Summary_df_annStatusRBP_Class = pd.concat([RBP_Dict_Cond1['Summary_df_annStatus'], RBP_Dict_Cond2['Summary_df_annStatus'], RBP_Dict_Cond3['Summary_df_annStatus']], axis=0, join='outer')#### And represent them in a barplotfrom matplotlib import pyplot as pltplt.figure('rbp class')sns.set_style('whitegrid')ax = sns.countplot(x='MQgroup', hue = 'RBP Class', data=RBP_Class, palette = cpal['RBP_Class'], edgecolor = 'black')ax.set_ylabel('Unique Gene Count')ax.set_title('Unique Genes detected per RBP Class')RBP_Class.head(1)| ENTREZGENE_gPro all | ENTREZGENE_gPro primary | ENTREZGENE_gPro name | Gene names | RBP Class | RBP subClass | MQgroup | |
|---|---|---|---|---|---|---|---|
| 0 | HDLBP;nan | HDLBP | high density lipoprotein binding protein [Sour... | HDLBP | I | Cond.1 |
#### If we are to look more closely at Summary_df_annStatus we can see it includes the subclasses of the RBP class 2 groupRBP_Dict_Cond1['Summary_df_annStatus'].head(10)| ENTREZGENE_gPro all | ENTREZGENE_gPro primary | ENTREZGENE_gPro name | Gene names | RBP Class | RBP subClass | MQgroup | |
|---|---|---|---|---|---|---|---|
| 0 | HDLBP;nan | HDLBP | high density lipoprotein binding protein [Sour... | HDLBP | I | Cond.1 | |
| 1 | RPS9 | RPS9 | ribosomal protein S9 [Source:HGNC Symbol;Acc:H... | RPS9 | II | b | Cond.1 |
| 2 | YTHDF3 | YTHDF3 | YTH N6-methyladenosine RNA binding protein 3 [... | YTHDF3 | NC | Cond.1 | |
| 3 | ELOA | ELOA | elongin A [Source:HGNC Symbol;Acc:HGNC:11620] | TCEB3 | NC | Cond.1 | |
| 5 | MRPS21;nan | MRPS21 | mitochondrial ribosomal protein S21 [Source:HG... | MRPS21 | NC | Cond.1 | |
| 6 | DCAF13 | DCAF13 | DDB1 and CUL4 associated factor 13 [Source:HGN... | DCAF13 | I | Cond.1 | |
| 10 | RPS29;nan | RPS29 | ribosomal protein S29 [Source:HGNC Symbol;Acc:... | RPS29 | NC | Cond.1 | |
| 11 | UHRF1;nan | UHRF1 | ubiquitin like with PHD and ring finger domain... | UHRF1 | NC | Cond.1 | |
| 13 | HNRNPDL | HNRNPDL | heterogeneous nuclear ribonucleoprotein D like... | HNRNPDL | I | Cond.1 | |
| 14 | RPS24;nan | RPS24 | ribosomal protein S24 [Source:HGNC Symbol;Acc:... | RPS24 | II | b | Cond.1 |
x
#### Because each subclass of the class II RBP are identified based on different statistical assumptions we can more closely inspect if those assumptions trend differently among the different conditions.plt.figure('rbp class')sns.set_style('whitegrid')ax = sns.countplot(x='MQgroup', hue = 'RBP subClass', data=RBP_Class[RBP_Class['RBP subClass']!=''].sort_values(by=['MQgroup','RBP subClass']), palette = cpal['Set3_qual'], edgecolor = 'black')ax.set_ylabel('Unique Gene Count')ax.set_title('Unique Genes detected per RBP Class')RBP_Class.head(1)| ENTREZGENE_gPro all | ENTREZGENE_gPro primary | ENTREZGENE_gPro name | Gene names | RBP Class | RBP subClass | MQgroup | |
|---|---|---|---|---|---|---|---|
| 0 | HDLBP;nan | HDLBP | high density lipoprotein binding protein [Sour... | HDLBP | I | Cond.1 |
x
## 15. Compare RBP Identity Between Conditions Here we use the dictionaries output by __jtest.MQ_applyClassifyRBP( )__ for the purposes of creating a Venn Diagram.15. Compare RBP Identity Between Conditions
Here we use the dictionaries output by jtest.MQ_applyClassifyRBP( ) for the purposes of creating a Venn Diagram.
from matplotlib import pyplot as pltimport numpy as npfrom matplotlib_venn import venn3, venn3_circlesplt.figure(figsize=(6,6))v = venn3([set(RBP_Dict_Cond1['I']['ENTREZGENE_gPro primary']), set(RBP_Dict_Cond2['I']['ENTREZGENE_gPro primary']), set(RBP_Dict_Cond3['I']['ENTREZGENE_gPro primary'])], set_labels = ('RBP_Dict_Cond1', 'RBP_Dict_Cond2', 'RBP_Dict_Cond3'), alpha = 0.5)c = venn3_circles([set(RBP_Dict_Cond1['I']['ENTREZGENE_gPro primary']), set(RBP_Dict_Cond2['I']['ENTREZGENE_gPro primary']), set(RBP_Dict_Cond3['I']['ENTREZGENE_gPro primary'])], linestyle='dashed')c[0].set_lw(1.5)c[0].set_ls('dotted')c[1].set_lw(1.5)c[1].set_ls('dotted')c[2].set_lw(1.5)c[2].set_ls('dotted')for text in v.set_labels: text.set_fontsize(18)for text in v.subset_labels: text.set_fontsize(14)xxxxxxxxxx## 16. Compare RBP Isoelectric Points Between Conditions__Functions__ jinspect.getIsoelectricPoints( ) jinspect.getIsoelectricPointsByClassDict( ) jwrangle.SplitList( ) Many algorithms exist for the calculation of isoelectric points (pI) by sequence analysis. Rather than calculating this data on the fly, I like to use a precalculated database published by Kozlowski 2016 and provided at isoelectricpointdb.org. This database provides precalculated pIs according to a variety of published models, and also an average pI which spans the most consisten algorithms. The function __jinspect.getIsoelectricPointsByClassDict( )__ will retrieve, as a list, all pIs associated with the proteins in our Class Dictionaries. The lists include all members of the Majority Protein Group that are associated with the identified gene; thus one gene may return more than one pI. This is a deliberate choice; because shotgun proteomics cannot properly discriminate between protein isoforms one sequence cannot be selected to solely represent a gene wihtout introducing user-bias. The majority protein groups is a best guess of the isoforms present and thus the pIs for each reported.If users wish to curate their own list for pI reporting they should instead use __jinspect.getIsoelectricPoints( )__. To do so we'll use __jwrangle.SplitList( )__ to create a list of proteins from instrument QC data and then retrieve the relevant pI data. 16. Compare RBP Isoelectric Points Between Conditions¶
Functions
jinspect.getIsoelectricPoints( )
jinspect.getIsoelectricPointsByClassDict( )
jwrangle.SplitList( )
Many algorithms exist for the calculation of isoelectric points (pI) by sequence analysis. Rather than calculating this data on the fly, I like to use a precalculated database published by Kozlowski 2016 and provided at isoelectricpointdb.org. This database provides precalculated pIs according to a variety of published models, and also an average pI which spans the most consisten algorithms. The function jinspect.getIsoelectricPointsByClassDict( ) will retrieve, as a list, all pIs associated with the proteins in our Class Dictionaries. The lists include all members of the Majority Protein Group that are associated with the identified gene; thus one gene may return more than one pI. This is a deliberate choice; because shotgun proteomics cannot properly discriminate between protein isoforms one sequence cannot be selected to solely represent a gene wihtout introducing user-bias. The majority protein groups is a best guess of the isoforms present and thus the pIs for each reported.
If users wish to curate their own list for pI reporting they should instead use jinspect.getIsoelectricPoints( ). To do so we'll use jwrangle.SplitList( ) to create a list of proteins from instrument QC data and then retrieve the relevant pI data.
#### Read in isoelectric point database (download from isoelectricpointdb.org)dfisoelectric_point_database = pd.read_csv(base_path / 'downloads' / 'isoelectric_points' / '180822_HUMAN_isoelectricpointdb-org_edit.csv', index_col=False)#### Calculate the pIs for every protein detected in each classRBP_Dict_Cond1_pI = jinspect.getIsoelectricPointsByClassDict(RBP_Dict_Cond1, dfisoelectric_point_database)RBP_Dict_Cond2_pI = jinspect.getIsoelectricPointsByClassDict(RBP_Dict_Cond2, dfisoelectric_point_database)RBP_Dict_Cond3_pI = jinspect.getIsoelectricPointsByClassDict(RBP_Dict_Cond3, dfisoelectric_point_database)#### Inspect the keys for each pI dictionaryRBP_Dict_Cond3_pI.keys()dict_keys(['I_pI', 'IIa_pI', 'IIb_pI', 'IIc_pI', 'ND_pI', 'II_pI'])
#### For comparison we'll also import a proteins typically found in a whole proteome analysis #### To do this we'll grab some HeLa digest quality control data from the same instrument these experiments were run onhela_qc = pd.read_csv(base_path / 'my_resources' / 'instrumentQC' / 'QE_191215' / 'proteinGroups.txt', delimiter='\t',index_col=False)### Create a new list from the Majority protein IDs and get pIshela_qcProt = jwrangle.SplitList(hela_qc['Majority protein IDs'].tolist(), [';','-'], replace = '$&', remove_nonstring_values = True, drop_empty_strings = True)hela_qc_pI = jinspect.getIsoelectricPoints(hela_qcProt, dfisoelectric_point_database)hela_qc_pI.head(2)| header | sequence | molecular_weight | Bjellqvist | DTASelect | Dawson | EMBOSS | Grimsley | IPC_peptide | IPC_protein | ... | Patrickios | ProMoST | Rodwell | Sillero | Solomon | Thurlkill | Toseland | Wikipedia | Avg_pI | edit: Uniprot ID | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 57678 | >tr|H7C1Q6|H7C1Q6_HUMAN Isoform of Q9NXE4 Sph... | XHNKVQFTPTGGLGLNLALNPFEYYIFFFALSLITQKPLPVSLHV... | 83146.83 | 9.048 | 8.858 | 8.916 | 9.063 | 8.521 | 8.975 | 8.170 | ... | 4.329 | 8.682 | 8.975 | 9.151 | 8.990 | 8.916 | 8.302 | 9.004 | 8.853 | H7C1Q6 |
| 28159 | >tr|A6NML8|A6NML8_HUMAN Isoform of O60879 Dia... | MEQPGAAASGAGGGSEEPGGGRSNKRSAGNRAANEEETKNKPKLN... | 124853.43 | 6.071 | 6.440 | 6.033 | 6.376 | 6.211 | 6.046 | 5.855 | ... | 4.596 | 6.135 | 6.008 | 6.364 | 6.033 | 6.415 | 6.109 | 6.008 | 6.150 | A6NML8 |
2 rows × 22 columns
plt.figure('Condition 1 OdT RBP Classes: Isoelectric Points')sns.set_style('whitegrid')ax = sns.kdeplot(hela_qc_pI['Avg_pI'], label = 'Proteome', shade = True, alpha = 0.2)ax = sns.kdeplot(RBP_Dict_Cond1_pI['I_pI'], label = 'Class I')ax = sns.kdeplot(RBP_Dict_Cond1_pI['II_pI'], label = 'Class II')ax = sns.kdeplot(RBP_Dict_Cond1_pI['ND_pI'], label = 'Class ND')ax.set_title('Isoelectric Point: RBP Class (Cond.1)', size = 16)plt.ylabel('Density', size = 14)plt.xlabel('pI', size = 14)plt.legend()plt.tight_layout()sns.despine()plt.close<function matplotlib.pyplot.close(fig=None)>
plt.figure('Condition 2 OdT RBP Classes: Isoelectric Points')sns.set_style('whitegrid')ax = sns.kdeplot(hela_qc_pI['Avg_pI'], label = 'Proteome', shade = True, alpha = 0.2)ax = sns.kdeplot(RBP_Dict_Cond2_pI['I_pI'], label = 'Class I')ax = sns.kdeplot(RBP_Dict_Cond2_pI['II_pI'], label = 'Class II')ax = sns.kdeplot(RBP_Dict_Cond2_pI['ND_pI'], label = 'Class ND')ax.set_title('Isoelectric Point: RBP Class (Cond.2)', size = 16)plt.ylabel('Density', size = 14)plt.xlabel('pI', size = 14)plt.legend()plt.tight_layout()sns.despine()plt.close<function matplotlib.pyplot.close(fig=None)>
plt.figure('Condition 3 OdT RBP Classes: Isoelectric Points')sns.set_style('whitegrid')ax = sns.kdeplot(hela_qc_pI['Avg_pI'], label = 'Proteome', shade = True, alpha = 0.2)ax = sns.kdeplot(RBP_Dict_Cond3_pI['I_pI'], label = 'Class I')ax = sns.kdeplot(RBP_Dict_Cond3_pI['II_pI'], label = 'Class II')ax = sns.kdeplot(RBP_Dict_Cond3_pI['ND_pI'], label = 'Class ND')ax.set_title('Isoelectric Point: RBP Class (Cond.3)', size = 16)plt.ylabel('Density', size = 14)plt.xlabel('pI', size = 14)plt.legend()plt.tight_layout()sns.despine()plt.close<function matplotlib.pyplot.close(fig=None)>
xxxxxxxxxx17. Compare RBP Class I Identity with Previous Studies
Functions
jwrangle.ListsToDataFrameSets( )
jwrangle.importMixedFiles( )
Comparing RBP candidates to those of other studies often relies on retrieving previously prepared lists and dataframes. For this we can use jwrangle.importMixedFiles() or read them directly from a resources folder (you'll need to set up your own).
After retrieving the relevant lists we can create upsetplots for inspecting data. The function jwrangle.ListsToDataFrameSets() helps here by creating multi index dataframes for plotting.
A number of cells are hashed out below. This is because they focus on once-only data wrangling of published data which, once complete, can be saved locally as a new copy and read in for future work. It is kept in this tutorial as an example of how functions such as jweb.mapAnyID_gPro( ) can be used on third party data.
#### Import the resources directory# Hentze_2018 = jwrangle.importMixedFiles(base_path / 'downloads' / 'published_data' / '2018_Hentze_Nature_Reviews_s2table')# Hentze_2018.keys()#### In this example we want the Human Datasets# Hentze_2018_Hs = Hentze_2018['Hs.csv']# Hentze_2018_Hs.head(2)#### That table produces an ugly import, let's fix up the headers and empty cells# r1 = Hentze_2018_Hs.columns.tolist()# r2 = Hentze_2018_Hs.loc[0,:].replace(np.nan, '').tolist()# r3 = []# for index, label in enumerate(r1):# r = label + ' (' + r2[index] + ')'# r = r.replace(' ()', '')# r3.append(r) # Hentze_2018_Hs.columns = r3# Hentze_2018_Hs = Hentze_2018_Hs.iloc[1:,:13]# Hentze_2018_Hs.head(2)#### To ensure naming consistency we will remap the ENSEMBL genes to ENTREZGENE.#### I've prefer ENTREZGENE because it shares the same conventions as Uniprot, QuickGo, and MaxQuant.# Hentze_2018_Hs_remap = jweb.mapAnyID_gPro(Hentze_2018_Hs['ID'].tolist(), splitstr = 'nosplit', geneProductType = 'gene', # gConvertOrganism = 'hsapiens', gConvertTarget = 'ENTREZGENE', writetopath = [cwd, 'Hentze_2018_Hs_remap'], writeTargetsAsList = 'NO')#### For posterity, let's add the remapped gene names to the original dataframe and save it as an edited copy in our resources folder.# Hentze_id_map = Hentze_2018_Hs_remap['id_map'].rename(columns={'Query': 'ID'}).drop_duplicates()# Hentze_2018_Hs_edit = pd.merge(Hentze_2018_Hs, Hentze_id_map, on='ID', how='left')# Hentze_2018_Hs_edit.to_csv(base_path / 'downloads' / 'published_data' / 'Hentze_2018_Hs_edit.csv', index = False )# Hentze_2018_Hs_edit.head(2)#### If not already loaded, read in the remapped resource dataHentze_2018_Hs_edit = pd.read_csv(base_path / 'downloads' / 'published_data' / 'Hentze_2018_Hs_edit.csv')#### We'll focus on the HEK293T RBPs identified by Baltz and begin by extracting the Gene names and remapping them to ensure consistency.Baltz_HEK293_RIC = Hentze_2018_Hs_edit[Hentze_2018_Hs_edit['HEK293-RIC (Hs_Baltz2012)']=='YES']['ENTREZGENE_gPro primary']#### Create upset plot to inspect overlap between the HEK293T RBPs identified by Baltz, and the class I RBPs discovered by our protocol at different conditions.import upsetplot as upsetdict_list = {'Baltz_HEK293':list(set(Baltz_HEK293_RIC)), 'Cond.1':list(set(RBP_Dict_Cond1['I']['ENTREZGENE_gPro primary'])), 'Cond.2':list(set(RBP_Dict_Cond2['I']['ENTREZGENE_gPro primary'])), 'Cond.3':list(set(RBP_Dict_Cond3['I']['ENTREZGENE_gPro primary']))}upsetDF = jwrangle.ListsToDataFrameSets(dict_list)cols = upsetDF.columns.difference(['gene']).tolist()group_upsetDF = upsetDF.groupby(cols).size()plt.figure('Common Class I RBPs')ax = upset.plot(group_upsetDF,sort_by='cardinality', show_counts = True, facecolor= cpal['RBP_Class'][0], element_size =50)plt.title('Class I RBPs shared with Baltz', size = 16)plt.close<function matplotlib.pyplot.close(fig=None)>
<Figure size 432x288 with 0 Axes>
#### And what would the result be if we took all RBPs identified across the 7 published studies?dict_list = {'All RIC':list(set(Hentze_2018_Hs_edit['ENTREZGENE_gPro primary'])), 'Cond.1':list(set(RBP_Dict_Cond1['I']['ENTREZGENE_gPro primary'])), 'Cond.2':list(set(RBP_Dict_Cond2['I']['ENTREZGENE_gPro primary'])), 'Cond.3':list(set(RBP_Dict_Cond3['I']['ENTREZGENE_gPro primary']))}upsetDF = jwrangle.ListsToDataFrameSets(dict_list)cols = upsetDF.columns.difference(['gene']).tolist()group_upsetDF = upsetDF.groupby(cols).size()plt.figure('Common Class I RBPs')ax = upset.plot(group_upsetDF,sort_by='cardinality', show_counts = True, facecolor= cpal['Set1_qual'][3], element_size =50)plt.title('Class I RBPs shared with all OdT Publications', size = 16)plt.close<function matplotlib.pyplot.close(fig=None)>
<Figure size 432x288 with 0 Axes>
xxxxxxxxxx18. Compare RBP Class I pI distribution to Previous Studies
Functions
jweb.mapAnyID_gPro( )
jinspect.getIsoelectricPoints( )
jwrangle.SplitList( )
jwrangle.importMixedFiles( )
Comparing RBP candidates to those of other studies often relies on retrieving previously prepared lists and dataframes. For this we can use jwrangle.importMixedFiles() or read them directly from a resources folder (you'll need to set up your own).
After retrieving the relevant lists we can create upsetplots for inspecting data. The function jwrangle.ListsToDataFrameSets() helps here by creating multi index dataframes for plotting.
A number of cells are hashed out below. This is because they focus on once-only data wrangling of published data which, once complete, can be saved locally as a new copy and read in for future work. It is kept in this tutorial as an example of how functions such as jweb.mapAnyID_gPro( ) can be used on third party data.
#### Lets also draw the isoelectric profile comparison against Baltz. #### To do so we'll need to fetch the Unprot protein names and Baltz_protList = jwrangle.SplitList(Hentze_2018_Hs_edit[Hentze_2018_Hs_edit['HEK293-RIC (Hs_Baltz2012)']=='YES']['ID'].tolist(), [';','-'], replace = '$&', remove_nonstring_values = True, drop_empty_strings = True)#### Now we'll convert the ENSEMBL IDs from our resource table into Uniprot IDs and save the results locally# Baltz_HEK293_RICprot = jweb.mapAnyID_gPro(Baltz_protList, splitstr = 'nosplit', geneProductType = 'gene', gConvertOrganism = 'hsapiens', gConvertTarget = 'UNIPROTSWISSPROT', writetopath = [cwd, 'Baltz_HEK293_RICprot'], writeTargetsAsList = 'NO')#### If not already loaded, read in the mapped data and inspectBaltz_HEK293_RICprot = jwrangle.importMixedFiles(cwd / 'downloads' / 'Baltz_HEK293_RICprot', dropSuffix = 'yes')Baltz_HEK293_RICprot['id_map'].head(2)| Query | UNIPROTSWISSPROT_gPro all | UNIPROTSWISSPROT_gPro primary | UNIPROTSWISSPROT_gPro name | |
|---|---|---|---|---|
| 0 | ENSG00000276072 | None | None | None |
| 1 | ENSG00000275700 | Q9NY61 | Q9NY61 | apoptosis antagonizing transcription factor [S... |
### Now get pIsBaltz_HEK293_RICprot = jinspect.getIsoelectricPoints(Baltz_HEK293_RICprot['id_map']['UNIPROTSWISSPROT_gPro primary'].tolist(), dfisoelectric_point_database)Baltz_HEK293_RICprot.head(2)| header | sequence | molecular_weight | Bjellqvist | DTASelect | Dawson | EMBOSS | Grimsley | IPC_peptide | IPC_protein | ... | Patrickios | ProMoST | Rodwell | Sillero | Solomon | Thurlkill | Toseland | Wikipedia | Avg_pI | edit: Uniprot ID | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 7360 | >sp|P62847|RS24_HUMAN 40S ribosomal protein S2... | MNDTVTIRTRKFMTNRLLQRKQMVIDVLHPGKATVPKTEIREKLA... | 15423.19 | 10.789 | 10.789 | 11.140 | 11.477 | 11.169 | 11.272 | 10.511 | ... | 11.316 | 10.672 | 11.608 | 11.067 | 11.257 | 11.067 | 11.096 | 11.316 | 11.094 | P62847 |
| 7662 | >sp|Q01081|U2AF1_HUMAN Splicing factor U2AF 35... | MAEYLASIFGTEKDKVNCSFYFKIGACRHGDRCSRLHNKPTFSQT... | 27872.05 | 9.092 | 8.814 | 8.756 | 8.946 | 7.702 | 8.873 | 8.083 | ... | 4.724 | 8.595 | 8.785 | 9.180 | 8.887 | 8.873 | 7.775 | 8.712 | 8.704 | Q01081 |
2 rows × 22 columns
#### Now plot the pI comparison vs Class Iplt.figure('RBP purification vs Baltz RIC\nIsoelectric Points')sns.set_style('whitegrid')ax = sns.kdeplot(hela_qc_pI['Avg_pI'], label = 'Proteome', shade = True, alpha = 0.2)ax = sns.kdeplot(RBP_Dict_Cond3_pI['I_pI'], label = 'Class I', color = 'green')ax = sns.kdeplot(Baltz_HEK293_RICprot['Avg_pI'], label = 'Baltz RIC RBP', color = 'red')ax.set_title('RBP purification vs Baltz RIC\nIsoelectric Points', size = 16)plt.ylabel('Density', size = 14)plt.xlabel('pI', size = 14)plt.legend()plt.tight_layout()sns.despine()plt.close<function matplotlib.pyplot.close(fig=None)>
xxxxxxxxxx19. Review Basic Gene Ontology
Functions
jwrangle.importMixedFiles( )
jweb.fetchQuickGO_stats( )
In this section we will explore Gene Ontology (GO) memberships for the observed proteins. There is little use in applying statistical tests such as Gene Ontology Enrichment Analysis (GOEA) for these experiments; the combination of selection by RNA interaction and the comparative lack of deep RBP validation for many candidates would make such a study rather spurious. We can, however, investigate the frequency with which our identified RBPs appear in previous studies. In addition, we can use this frequency to further assess whether the 20% and 30% capture conditions used here are equivalent or not.
A number of GO-specific and utility functions are provided to help with retrieving Gene Ontologies from the QuickGo database. In this section we'll look at the most basic.
The function jweb.fetchQuickGO_stats( ) will fetch the annotation statistics for all records belonging to the gene ID from a submitted list. These statistics are generally of two types: no. of annotations (which relates to unique proteins) and no. of geneProducts (which relate to the gene count; poorly worded I know). The quality of these records is given by whether identification originates from a SwissPort or a TrEMBL entry. Reviewing these statistics before beginning an analysis is ideal, because it contextualises the breadth of future analyses. This function returns these statistics in the from of a dictionary which can be converted to a dataframe for easier viewing by using the dedicated function jweb.getQuickGO_stats( ).
In addition to contextualising the search space of subsequent analyses, fetching the annotation numbers is important for checking that the number of records, per GO ID, falls below 10000. This is because QuickGo will not allow larger searches to be done programmatically. If your GO ID of interest has many more records users should retrieve their records manually. These details will be covered fourther in the next section.
#### I like to keep a table of interesting GO terms in a local csv file, let's find itMyResources = jwrangle.importMixedFiles(base_path / 'my_resources')MyResources.keys()dict_keys(['.ipynb_checkpoints', 'control_elements', 'control_proteins', 'custom_dfs', 'FASTA', 'GOexplore.ipynb', 'GO_TermsOfInterest.csv', 'GO_TermsOfInterest_stats.csv', 'Hentze_core_RBP_list.txt', 'Hentze_core_RBP_list_uniprot.txt', 'Hentze_core_RBP_plusE1_8.txt', 'instrumentQC', 'limma_normalizeTIs_p3550_p3592_p3657.nb.html', 'limma_normalizeTIs_p3550_p3592_p3657.Rmd', 'TIs_p3550_p3592_p3657.csv', 'TIs_p3550_p3592_p3657_loess.csv'])
MyResources['GO_TermsOfInterest.csv'].head(5)| GO Term | relationship | depth | go ID | Description | ctrl list type | parent(s) | |
|---|---|---|---|---|---|---|---|
| 0 | binding | Molecular Function | 1 | GO:0005488 | NaN | NaN | GO:0003674 |
| 1 | protein binding | Molecular Function | 2 | GO:0005515 | NaN | NaN | GO:0005488 |
| 2 | chromatin binding | Molecular Function | 2 | GO:0003682 | NaN | NaN | GO:0005488 |
| 3 | nucleic acid binding | Molecular Function | 3 | GO:0003676 | NaN | NaN | GO:0003676 |
| 4 | DNA binding | Molecular Function | 4 | GO:0003677 | NaN | general | GO:0003676 |
# #### Let's get basic statistics on the all GO IDs listed from depth 3 down" # MyGO_Stats_Dict = jweb.fetchQuickGO_stats(MyResources['GO_TermsOfInterest.csv']['go ID'].tolist()[3:], QG_geneProductType = 'protein', QG_taxonId = '9606', QG_geneProductSubset = ['Swiss-Prot', 'TrEMBL'])# #### To view basic information, like the number of annotations associated with the GO term# MyGO_Stats = jweb.getQuickGO_stats(MyGO_Stats_Dict)# #### Save a local copy of the stats dataframe# MyGO_Stats_DF = pd.merge(MyResources['GO_TermsOfInterest.csv'], MyGO_Stats, on = 'go ID', how = 'outer')# MyGO_Stats_DF.to_csv(cwd / 'downloads' / 'MyGO_Stats_DF.csv', index = False)# #### View the DataFrame# MyGO_Stats_DF.head(50)#### Read a local copy and view DataFrameMyGO_Stats_DF = pd.read_csv(cwd / 'downloads' / 'MyGO_Stats_DF.csv')MyGO_Stats_DF.head(50)| GO Term | relationship | depth | go ID | Description | ctrl list type | parent(s) | Swiss-Prot_annotations | Swiss-Prot_genesProducts | TrEMBL_annotations | TrEMBL_genesProducts | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | binding | Molecular Function | 1 | GO:0005488 | NaN | NaN | GO:0003674 | NaN | NaN | NaN | NaN |
| 1 | protein binding | Molecular Function | 2 | GO:0005515 | NaN | NaN | GO:0005488 | NaN | NaN | NaN | NaN |
| 2 | chromatin binding | Molecular Function | 2 | GO:0003682 | NaN | NaN | GO:0005488 | NaN | NaN | NaN | NaN |
| 3 | nucleic acid binding | Molecular Function | 3 | GO:0003676 | NaN | NaN | GO:0003676 | 15714.0 | 4127.0 | 18207.0 | 9319.0 |
| 4 | DNA binding | Molecular Function | 4 | GO:0003677 | NaN | general | GO:0003676 | 9399.0 | 2603.0 | 9854.0 | 4772.0 |
| 5 | RNA binding | Molecular Function | 4 | GO:0003723 | NaN | general | GO:0003676 | 5245.0 | 1685.0 | 4976.0 | 2620.0 |
| 6 | DNA/RNA hybrid binding | Molecular Function | 4 | GO:0071667 | NaN | general | GO:0003676 | 0.0 | 0.0 | 0.0 | 0.0 |
| 7 | translation regulator activity | Molecular Function | 4 | GO:0090079 | NaN | NaN | GO:0003676 | 359.0 | 111.0 | 673.0 | 399.0 |
| 8 | regulatory region nucleic acid binding | Molecular Function | 4 | GO:0001067 | NaN | NaN | GO:0003676 | 2866.0 | 1514.0 | 608.0 | 554.0 |
| 9 | annealing activity | Molecular Function | 4 | GO:0097617 | NaN | NaN | GO:0003676 | 21.0 | 13.0 | 7.0 | 7.0 |
| 10 | ssDNA binding | Molecular Function | 5 | GO:0003697 | NaN | general | GO:0003677 | 221.0 | 120.0 | 100.0 | 96.0 |
| 11 | dsDNA binding | Molecular Function | 5 | GO:0003690 | NaN | general | GO:0003677 | 3780.0 | 1715.0 | 826.0 | 740.0 |
| 12 | ssRNA binding | Molecular Function | 5 | GO:0003727 | NaN | general | GO:0003723 | 165.0 | 88.0 | 36.0 | 35.0 |
| 13 | dsRNA binding | Molecular Function | 5 | GO:0003725 | NaN | general | GO:0003723 | 138.0 | 79.0 | 69.0 | 68.0 |
| 14 | mRNA binding | Molecular Function | 5 | GO:0003729 | NaN | general | GO:0003723 | 573.0 | 302.0 | 277.0 | 246.0 |
| 15 | pre-mRNA binding | Molecular Function | 5 | GO:0036002 | NaN | general | GO:0003723 | 48.0 | 38.0 | 21.0 | 17.0 |
| 16 | snRNA binding | Molecular Function | 5 | GO:0017069 | NaN | general | GO:0003723 | 97.0 | 47.0 | 18.0 | 16.0 |
| 17 | rRNA binding | Molecular Function | 5 | GO:0019843 | NaN | general | GO:0003723 | 95.0 | 64.0 | 72.0 | 61.0 |
| 18 | rRNA primary transcript binding | Molecular Function | 6 | GO:0042134 | NaN | NaN | GO:0019843 | 3.0 | 1.0 | 0.0 | 0.0 |
| 19 | 5S rRNA binding | Molecular Function | 6 | GO:0008097 | NaN | NaN | GO:0019843 | 16.0 | 11.0 | 10.0 | 10.0 |
| 20 | rRNA modification guide activity | Molecular Function | 6 | GO:0030556 | NaN | NaN | GO:0019843 | 0.0 | 0.0 | 0.0 | 0.0 |
| 21 | large ribosomal subunity rRNA | Molecular Function | 6 | GO:0070180 | NaN | NaN | GO:0019843 | 5.0 | 5.0 | 0.0 | 0.0 |
| 22 | small ribosomal subunit rRNA | Molecular Function | 6 | GO:0070181 | NaN | NaN | GO:0019843 | 10.0 | 10.0 | 0.0 | 0.0 |
| 23 | B-WICH complex | Molecular Function | 6 | GO:0110016 | A chromatin remodeling complex that positively... | NaN | GO:0019843 | 0.0 | 0.0 | 0.0 | 0.0 |
| 24 | 5.8S rRNA binding | Molecular Function | 6 | GO:1990932 | NaN | NaN | GO:0019843 | 0.0 | 0.0 | 0.0 | 0.0 |
| 25 | ribosome biogenesis | Biological Process | 4 | GO:0042254 | NaN | ribozero | GO:0022613 | 909.0 | 312.0 | 460.0 | 259.0 |
| 26 | ribosome assembly | Biological Process | 5 | GO:0042255 | NaN | ribozero | GO:0042254 | 85.0 | 66.0 | 25.0 | 22.0 |
| 27 | regulation of ribosome biogenesis | Biological Process | 5 | GO:0090069 | NaN | NaN | GO:0042254 | 19.0 | 16.0 | 2.0 | 2.0 |
| 28 | positive regulation of ribosome biogenesis | Biological Process | 5 | GO:0090070 | NaN | NaN | GO:0042254 | 11.0 | 10.0 | 0.0 | 0.0 |
| 29 | negative regulation of ribosome biogenesis | Biological Process | 5 | GO:0090071 | NaN | NaN | GO:0042254 | 5.0 | 5.0 | 1.0 | 1.0 |
| 30 | ribosomal large subunit biogenesis | Biological Process | 5 | GO:0042273 | NaN | NaN | GO:0042254 | 122.0 | 74.0 | 49.0 | 29.0 |
| 31 | ribosomal small subunit biogenesis | Biological Process | 5 | GO:0042274 | NaN | NaN | GO:0042254 | 124.0 | 73.0 | 18.0 | 17.0 |
| 32 | rRNA export from the nucleus | Biological Process | 5 | GO:0006407 | NaN | NaN | GO:0042254 | 2.0 | 2.0 | 0.0 | 0.0 |
| 33 | ribosomal subunit export from nucleus | Biological Process | 5 | GO:0000054 | NaN | NaN | GO:0042254 | 27.0 | 14.0 | 23.0 | 12.0 |
| 34 | rRNA processing | Biological Process | 5 | GO:0006364 | NaN | NaN | GO:0042254 | 590.0 | 227.0 | 254.0 | 152.0 |
| 35 | ribosome disassembly | Biological Process | 5 | GO:0032790 | NaN | NaN | GO:1903008 | 12.0 | 8.0 | 4.0 | 2.0 |
| 36 | ribosome localization | Biological Process | 4 | GO:0033750 | NaN | ribozero | GO:0008104;GO:0051640 | 27.0 | 14.0 | 23.0 | 12.0 |
| 37 | mitochondrial ribosome assembly | Biological Process | 6 | GO:0061668 | NaN | ribozero | GO:0042254 | 8.0 | 6.0 | 0.0 | 0.0 |
| 38 | mitochondrial ribosome | Cellular Component | 10 | GO:0005761 | NaN | ribozero | GO:000313;GO:0005759 | 251.0 | 88.0 | 26.0 | 25.0 |
| 39 | ribosome | Cellular Component | 8 | GO:0005840 | NaN | ribozero | GO:0043232 | 1400.0 | 234.0 | 1911.0 | 713.0 |
| 40 | polysomal ribosome | Cellular Component | 9 | GO:0042788 | NaN | NaN | GO:0005840 | 35.0 | 33.0 | 3.0 | 3.0 |
| 41 | organellar ribosome | Cellular Component | 9 | GO:0000313 | NaN | NaN | GO:0005840 | 251.0 | 88.0 | 26.0 | 25.0 |
| 42 | cytosolic ribosome | Cellular Component | 9 | GO:0022626 | NaN | NaN | GO:0005840 | 295.0 | 112.0 | 31.0 | 31.0 |
| 43 | structural constituent of ribosome | Cellular Component | 9 | GO:0003735 | NaN | NaN | GO:0005840 | 411.0 | 165.0 | 608.0 | 580.0 |
| 44 | ribosomal subunit | Cellular Component | 9 | GO:0044391 | NaN | NaN | GO:0005840 | 555.0 | 190.0 | 138.0 | 135.0 |
| 45 | RQC complex | Cellular Component | 2 | GO:1990112 | A multiprotein complex that forms a stable com... | ribozero | GO:0032991 | 3.0 | 2.0 | 6.0 | 3.0 |
| 46 | ribonucleoprotein complex binding | Molecular Function | 3 | GO:0043021 | NaN | ribozero | GO:0044877 | 196.0 | 135.0 | 84.0 | 78.0 |
| 47 | ribosome binding | Molecular Function | 4 | GO:0043022 | NaN | ribozero | GO:0043021 | 81.0 | 60.0 | 47.0 | 43.0 |
| 48 | mitochondrial ribosome binding | Molecular Function | 5 | GO:0097177 | NaN | ribozero | GO:0043022 | 6.0 | 5.0 | 0.0 | 0.0 |
| 49 | mitochondrion | Cellular Component | 5 | GO:0005739 | NaN | NaN | GO:0043231;GO:0005737 | 10259.0 | 1677.0 | 34454.0 | 13352.0 |
xxxxxxxxxx20. Retrieve GO Records
Functions
jweb.fetchQuickGO( )
jwrangle.concatGO_DataFrameDict( )
jweb.mapQuickGO( )
We can see above that none of our downloaded IDs have exceeded our fetch limit of 10000 records. If any did, we would need to manually retrieve the tsv file.
For the GO terms we wish to investigate to investigate jweb.fetchQuickGO( ) will fetch the relevant proteins and also apply the same onsistent gene ID mapping algorithm we used earlier when remapping the MaxQuant IDs. This process is important because it allows us to provide consistent gene IDs to subsequent sets analysis. Where the writetopath options is used, the results from any searches will be saved to a local downloads folder- this is useful as a snapshot of the annotations used at the time or as a simple way of avoiding fetching the records via API in the future.
The function jwrangle.concatGO_DataFrameDict( ) let's us concatenate a dictionary created by jweb.fetchQuickGO( ). This is useful when the user wishes to pool both SwissProt and TrEMBL records for a given
A Note on Manual Downloads
The jweb.fetchQuickGO( ) will also output to console the html address that one should use if a manual download if required; this address will encompass all the relevant record characteristics that typically used by this suite. Once this table has been downloaded, the function jweb.mapQuickGO( ) can be used to provide the same ID mapping service as performed in jweb.fetchQuickGO( ). The returned elements will also be manipulated into the same format.
#### Download and create a local copy of all the records associated with our GO query from depth 4 onwards. # QuickGo_dict = jweb.fetchQuickGO(MyGO_Stats_DF['go ID'][4:], QG_geneProductType = 'protein', QG_taxonId = '9606', QG_geneProductSubset = ['Swiss-Prot', 'TrEMBL'], gConvertOrganism='hsapiens', writetopath= True)#### To avoid future API requests we will load the saved files....QuickGo_dict = jwrangle.importMixedFiles(cwd / 'downloads' / 'QuickGo')#### ....and concatenate all SwissProt and TrEMBL entries into a single dictionary.QuickGo_dict_concat = jwrangle.concatGO_DataFrameDict(QuickGo_dict)QuickGo_dict_concat.keys()dict_keys(['GO0000054', 'GO0000313', 'GO0001067', 'GO0003677', 'GO0003690', 'GO0003697', 'GO0003723', 'GO0003725', 'GO0003727', 'GO0003729', 'GO0003735', 'GO0005739', 'GO0005761', 'GO0005840', 'GO0006364', 'GO0006407', 'GO0008097', 'GO0017069', 'GO0019843', 'GO0022626', 'GO0030556', 'GO0032790', 'GO0033750', 'GO0036002', 'GO0042134', 'GO0042254', 'GO0042255', 'GO0042273', 'GO0042274', 'GO0042788', 'GO0043021', 'GO0043022', 'GO0044391', 'GO0061668', 'GO0070180', 'GO0070181', 'GO0071667', 'GO0090069', 'GO0090070', 'GO0090071', 'GO0090079', 'GO0097177', 'GO0097617', 'GO0110016', 'GO1990112', 'GO1990932'])
xxxxxxxxxx21. Analyse GO Memberships #1: RNA-binding
Functions
jwrangle.AnnotateDataFrameCtrls( )
jinspect.MQ_getFrequencyBySample( )
The function jwrangle.AnnotateDataFrameCtrls( ) takes our QuickGo records and annotates each protein or gene in a given dataframe (i.e. a proteinGroups table) for membership to the searched GO ID. The function jinspect.MQ_getFrequencyBySample( ) acts similarly to the peptide and gene count functions used earlier- it will sum the frequency of memberships to each GO catgeory and report the counts as a modified metadata table.
#### With our GO records in hand we next investigate whether our identified proteins are members of our GO IDs#### Let's start by looking at only GO:0003723. First, dedicate a dictionary to this searchdict_GO0003723 = {'GO0003723': QuickGo_dict_concat['GO0003723']}#### Next, annotate the last version of our modified proteinGroups table pGroup_GO0003723 = jwrangle.AnnotateDataFrameCtrls(pGroup_Freq, dict_GO0003723, search_match = 'ENTREZGENE_gPro primary', dict_match = 'ENTREZGENE_gPro primary', none_col = 'GO_None')#### Next find the counts for each GO ID being searched we will modify our metadata table in a fashion in the same way as for prptide and gene counting.#### We'll use iBAQ for these counts but, given all intensities have previously been filtered by LFQ membership both 'Intensity' or 'LFQ intensity' would give the same result.metaStatsGO0003723 = jinspect.MQ_getFrequencyBySample(pGroup_GO0003723['ann_df'], metaStats, freqList = list(dict_GO0003723.keys()) + ['GO_None'], measure = 'iBAQ')#### Now Calculate the % GO0003723 members per groupmetaStatsGO0003723['% RBP'] = metaStatsGO0003723.apply(lambda row: round(100*row['GO0003723']/(row['GO0003723']+row['GO_None'])), axis = 1)#### Plotjvis.BarPlotByGroup_sbplot(metaStatsGO0003723, x_col = 'condition', y_col = '% RBP', title = 'GO:0003723, RNA-Binding', pal = set2_paired, yrange = [0,110])D:\MEGA\Programming\Scripts_JS\RBP_SUITE\modules\jwrangle.py:40: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy ctrl_nohits_df[none_col] = True #add zero annotation column to annotation columns
<Figure size 432x288 with 0 Axes>
xxxxxxxxxx21. Analyse GO Memberships #1: Nucleic Acid Binding
Functions
jwrangle.AnnotateDataFrameCtrls( )
jinspect.MQ_getFrequencyBySample( )
jinspect.MQ_getMeans( )
The function jwrangle.AnnotateDataFrameCtrls( ) takes our QuickGo records and annotates each protein or gene in a given dataframe (i.e. a proteinGroups table) for membership to the searched GO ID. The function jinspect.MQ_getFrequencyBySample( ) acts similarly to the peptide and gene count functions used earlier- it will sum the frequency of memberships to each GO catgeory and report the counts as a modified metadata table. Finally, the function jinspect.MQ_getMeans( ) will make it easy for us to calculate the means across any specific group in our metadata; essentially it acts like a native python 'groupby'.
xxxxxxxxxx#### Let's create a QuickGo dictionary of proteins/genes with nucleic acid binding properties (depth 5). These have been marked as 'general' under the 'ctrl list type' column of our GO_stats dataframe.list_NA = MyGO_Stats_DF[MyGO_Stats_DF['ctrl list type']=='general']['go ID'].apply(lambda x: x.replace(':','')).tolist()dict_NA = {}for key, value in QuickGo_dict_concat.items(): if key in list_NA: dict_NA[key] = value#### Next, annotate the last version of our modified proteinGroups table pGroup_NA = jwrangle.AnnotateDataFrameCtrls(pGroup_Freq, dict_NA, search_match = 'ENTREZGENE_gPro primary', dict_match = 'ENTREZGENE_gPro primary', none_col = 'GO_None')#### Next find the counts for each GO ID being searched we will modify our metadata table in a fashion in the same way as for peptide and gene counting.#### We'll use LFQ intensity for these counts but, given all intensities have previously been filtered by LFQ membership both 'Intensity' or 'iBAQ' would give the same result.metaStats_NA = jinspect.MQ_getFrequencyBySample(pGroup_NA['ann_df'], metaStats, freqList = list(dict_NA.keys()) + ['GO_None'], measure = 'LFQ intensity')#### Calculate the means for our selected groupsmeans_NA = jinspect.MQ_getMeans(metaStats_NA, [i for i in metaStats_NA.columns if 'GO' in i], group = 'condition')#### Relabel the GO IDs with names to make reading easierMyGO_IDs = dict(zip([i.replace(':','') for i in MyGO_Stats_DF['go ID'].tolist()], MyGO_Stats_DF['GO Term'])) col_names = []for i in list(means_NA.columns): if 'GO0' in i: for key, value in MyGO_IDs.items(): if key in i: col_names.append(i.replace(key, value)) else: col_names.append(i) means_NA.columns = col_names means_NA| DNA binding | dsDNA binding | ssDNA binding | RNA binding | dsRNA binding | ssRNA binding | mRNA binding | snRNA binding | rRNA binding | pre-mRNA binding | DNA/RNA hybrid binding | GO_None | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Cond.1_nCL | 12 | 3 | 2 | 26 | 1 | 4 | 12 | 1 | 1 | 3 | 0 | 1 |
| Cond.1_254 | 130 | 53 | 20 | 574 | 28 | 33 | 128 | 13 | 33 | 19 | 0 | 52 |
| Cond.2_nCL | 9 | 2 | 2 | 12 | 0 | 3 | 6 | 0 | 0 | 2 | 0 | 0 |
| Cond.2_254 | 148 | 61 | 24 | 688 | 31 | 38 | 145 | 24 | 37 | 22 | 0 | 89 |
| Cond.3_nCL | 10 | 2 | 2 | 16 | 1 | 4 | 8 | 1 | 0 | 3 | 0 | 1 |
| Cond.3_254 | 181 | 78 | 29 | 791 | 35 | 41 | 159 | 28 | 41 | 22 | 0 | 147 |
#### Use the native method .stack() to create a DataFrame for the stakced histogrammeans_NA_stack = means_NA.stack().reset_index()means_NA_stack.columns=['condition', 'GO code', 'mean count']means_NA_stack = means_NA_stack.sort_values(['condition'])means_NA_stack.head(3)#### Chart Nucleic Acid GO memberships in a stacked histogramchart = alt.Chart(means_NA_stack ).mark_bar(cornerRadiusBottomRight=0, cornerRadiusTopRight=0, stroke='black', fillOpacity=0.7, strokeWidth=0.5, ).encode(x='sum(mean count):Q', y='condition:N', color=alt.Color('GO code:N', scale=alt.Scale(scheme='Set3')) ).properties(height=200, width=400, title = 'GO memberships: Nucleic Acids')chart.configure_title(fontSize = 15, fontWeight='normal' ).configure_axis(labelFontSize=14, labelFontWeight='normal', titleFontSize = 14, titleFontWeight='normal' ).configure_legend(titleFontSize = 14, titleFontWeight='normal', symbolStrokeWidth = 0.5, labelFontSize = 13)